Staking
- Claim FRA Token Rewards
This function enables users to claim rewards earned from staking FRA tokens.
<WalletKeypar>
- Wallet keypair<string>
- the amout of rewards which users wants to claim
Promise<TransactionBuilder>
- TransactionBuilder which should be used inTransaction.submitTransaction
.
const walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);
â
// First, we create a transaction builder
const assetBuilder = await Asset.defineAsset(walletInfo, assetCode);
â
// Then, we submit a transaction
const handle = await Transaction.submitTransaction(assetBuilder);
- Delegates FRA tokens
This function allows users to delegate FRA tokens to a validator.
This functionality is nearly identical to Transaction.sendToAddress except it adds one additional operation (i.e. add_operation_delegate) to the transaction builder.
<WalletKeypar>
- Wallet keypair<string>
- Target address for delegation<string>
- delegation amout<string>
- Asset Code<string>
- Target validator Address<AssetBlindRules>
- (optional) Confidential options for blind rule
Promise<TransactionBuilder>
- TransactionBuilder which should be used inTransaction.submitTransaction
.
const ledger = await getLedger();
â
// This is the address funds are sent to.
// Actual `transfer to validator` process would be handled via added `add_operation_delegate` operation
â
const delegationTargetPublicKey = Ledger.get_delegation_target_address();
const delegationTargetAddress = await Keypair.getAddressByPublicKey(
delegationTargetPublicKey
);
â
const walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);
â
const assetCode = await Asset.getFraAssetCode();
â
const assetBlindRules: Asset.AssetBlindRules = {
isTypeBlind: false,
isAmountBlind: false,
};
â
const transactionBuilder = await StakingApi.delegate(
walletInfo,
delegationTargetAddress,
amount,
assetCode,
validatorAddress,
assetBlindRules
);
â
const resultHandle = await Transaction.submitTransaction(transactionBuilder);
- Get the delegation information
This method is used to get the delegation information
<string>
- wallet address
Promise<DelegateInfoResponse>
- An instance ofDelegateInfoDataResult
containing the response and error..
const address = "fra123sxde";
â
// Get the delegation information
const delegateInfo = await StakingApi.getDelegateInfo(address);
- Get validator list
This method is used to get the list of validators.
Promise<validatorListResponse>
- An instance ofvalidatorListResponse
containing the response and error..
// Get validator list
const validatorList = await StakingApi.getValidatorList();
- Unstake FRA tokens
This function allows users to unstake (aka unbond) FRA tokens.
<WalletKeypar>
- Wallet keypair<string>
- the amount users wants to unstake<string>
- validator's address<boolean>
- fully unstake option. Default isfalse
Promise<TransactionBuilder>
- TransactionBuilder which should be used inTransaction.submitTransaction
.
const walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);
â
// Define whether or not user desires to unstake all the tokens, or only part of the staked amount
const isFullUnstake = false;
â
const transactionBuilder = await StakingApi.unStake(
walletInfo,
amount,
validator,
isFullUnstake
);
â
const resultHandle = await Transaction.submitTransaction(transactionBuilder);y
Last modified 4mo ago