Stake KLIMA

Staking KLIMA via Solidity

Requirements

1. Transfer KLIMA to your contract

You can transfer KLIMA tokens to your contract via web3.js and JSON RPC (like using Metamask) or choose to implement a deposit function that calls KLIMA's standard ERC20 approve and transfer functions to allow your contract to transfer users' KLIMA tokens to your contract.

2. Approving the StakingHelper contract

Your contract's function calls the KLIMA token's standard ERC20 approve function to allow the StakingHelper contract to withdraw KLIMA tokens from your contract. In the example below, an interface named IERC20 to interact with the KLIMA token smart contact.

3. Staking KLIMA tokens

Your contract's function calls the StakingHelper contract's stake function. In the example below, an interface named IStakingHelper is used to interact with the StakingHelper contract.

Once staked, you will receive a proportional amount of sKLIMA to represent the staked KLIMA. sKLIMA is an ERC20 and can transferred using the IERC20 interface.

Example

Unstaking KLIMA via Solidity

Requirements

  • Get some MATIC to pay for gas fees

  • Get some sKLIMA tokens to unstake

  • Get the contract addresses from here:

The following assumes your contract already holds sKLIMA. You can follow the same steps above to transfer sKLIMA to your contract if necessary.

1. Approving the Staking contract

Your contract's function calls the sKLIMA token's standard ERC20 approve function to allow the Staking contract to withdraw sKLIMA tokens from your contract. In the example below, an interface named IERC20 to interact with the sKLIMA token smart contact.

2. Unstaking sKLIMA tokens

Your contract's function calls the Staking contract's unstake function. In the example below, an interface named IStaking is used to interact with the Staking contract. The default value for bool _trigger is false unless you wish to trigger the rebase.

Once unstaked, you will receive a proportional amount of KLIMA. KLIMA is an ERC20 and can transferred using the IERC20 interface.

Example

Last updated

Was this helpful?