Skip to main content
The following code snippets show an example of how you can integrate the Spirals vault contracts into your smart contracts. Please create a new file GreenTokenVaultInterface.sol in your project to import the interface in your contract files and get started on these code examples πŸ‘‡

Depositing into vault

Once again, we start with a simple example where the contract being integrated deposit _amount of token into the vault.
For native tokens like ETH and Celo, use depositETH(address _receiver) payable

Reading gToken balances

Similarly, we can also pretty easily read the gToken balances using the method that’s available on the interface.
Now let’s put the 2 snippets together so that on deposit we return the amount of gTokens the receiver gets through a deposit function call.

Putting it together

Sweet! Now we have a full end-to-end example of a smart contract that deposits an ERC-20 token into the gToken vault on behalf of a receiver and returns the amount of gTokens received 😀