Staking
Cryptum SDK currently only supports staking methods for the Celo blockchain.
To stake CELO you have to follow these steps below:
- Register your account if it isn't registered yet
- Lock tokens
- Vote for validator group
- Activate your votes
To unstake you have the following steps to do:
- Revoke active votes from validator group
- Unlock tokens
- Withdraw tokens
Use the transaction controller to make the following calls:
const sdk = new CryptumSdk({
environment: 'testnet',
apiKey: 'YOUR-API-KEY'
})
opts.address
(string) (required) - wallet address.
const summary = await sdk.staking.celo.getAccountSummary({
address: '0xaaaaaaaaaaaaa',
}))
// summary {
// total: '2.781313429852',
// nonvoting: '1.01',
// pendingWithdrawals: [ { amount: '0.002882006678210218', timestamp: '1625704512' } ],
// votes: [
// {
// group: '0x5edfCe0bad47e24E30625c275457F5b4Bb619241',
// pending: '0',
// active: '1.771313429852'
// }
// ]
// }
Check if account is registered already for staking.
opts.address
(string) (required) - wallet address.
const { result } = await sdk.staking.celo.isRegisteredAccount({
address: '0xaaaaaa'
}))
Register account.
opts.wallet
(Wallet) (required) - wallet to be registered.
const transaction = await sdk.staking.celo.registerAccount({ wallet }))
opts.wallet
(Wallet) (required) - wallet used to lock the amount with.opts.amount
(string) (required) - amount to be locked.
const transaction = await sdk.staking.celo.lock({ wallet, amount: '0.22' }))
opts.wallet
(Wallet) (required) - wallet used to vote.opts.amount
(string) (required) - Celo amount used to vote.opts.validator
(string) (required) - validator group address.
const transaction = await sdk.staking.celo.vote({
wallet,
amount: '1.77',
validator: '0xbbbbbbbb',
}))
Before activating, you'll need to wait for the next epoch to begin. One epoch lasts around one day.
opts.wallet
(Wallet) (required) - wallet used to activate.opts.validator
(string) (required) - validator group address.
const transaction = await sdk.staking.celo.activate({
wallet,
validator: '0xbbbbbbbb',
}))
opts.wallet
(Wallet) (required) - wallet used to revoke pending votes.opts.amount
(string) (required) - Celo amount used to revoke.opts.validator
(string) (required) - validator group address to revoke from.
const transaction = await sdk.staking.celo.revokePending({
wallet,
amount: '1',
validator: '0x5555555555',
}))
opts.wallet
(Wallet) (required) - wallet used to revoke active votes.opts.amount
(string) (required) - Celo amount used to revoke.opts.validator
(string) (required) - validator group address to revoke from.
const transaction = await sdk.staking.celo.revokeActive({
wallet,
amount: '0.2218',
validator: '0xcccccccccccccc',
}))
opts.wallet
(Wallet) (required) - wallet used to unlock amount.opts.amount
(string) (required) - Celo amount used to unlock.
const transaction = await sdk.staking.celo.unlock({
wallet,
amount: '0.01218',
}))
Use this method to withdraw pending amounts. After unlocking the tokens you have to wait for 3 days to withdraw.
opts.address
(string) (required) - wallet address to get the pending withdrawals from.
const pendingWithdrawals = await sdk.staking.celo.getPendingWithdrawals({
address: '0xaaaaaaaaaa',
}))
opts.wallet
(Wallet) (required) - wallet used to withdraw.opts.index
(number) (required) - index of pending withdrawals.
const transaction = await sdk.staking.celo.withdraw({ wallet, index: 1 }))
Relock tokens that are pending withdrawals.
opts.wallet
(Wallet) (required) - wallet used to withdraw.opts.amount
(string) (required) - amount to relock.opts.index
(number) (required) - index of pending withdrawals.
const transaction = await sdk.staking.celo.relock({
wallet,
amount: '0.01218',
index: 0,
}))
Last modified 1mo ago