Staking
claim​
- Claim FRA Token Rewards
This function enables users to claim rewards earned from staking FRA tokens.
Parameters:​
- Â
<WalletKeypar>
- Wallet keypair - Â
<string>
- the amout of rewards which users wants to claim
Results:​
- Â
Promise<TransactionBuilder>
- TransactionBuilder which should be used inTransaction.submitTransaction
.
Example:​
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);
delegate​
- 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.
Parameters:​
- Â
<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
Results:​
- Â
Promise<TransactionBuilder>
- TransactionBuilder which should be used inTransaction.submitTransaction
.
Example:​
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);
getDelegateInfo​
- Get the delegation information
This method is used to get the delegation information
Parameters:​
- Â
<string>
- wallet address
Results:​
- Â
Promise<DelegateInfoResponse>
- An instance ofDelegateInfoDataResult
containing the response and error..
Example:​
const address = "fra123sxde";
// Get the delegation information
const delegateInfo = await StakingApi.getDelegateInfo(address);
getValidatorList​
- Get validator list
This method is used to get the list of validators.
Results:​
- Â
Promise<validatorListResponse>
- An instance ofvalidatorListResponse
containing the response and error..
Example:​
// Get validator list
const validatorList = await StakingApi.getValidatorList();
unStake​
- Unstake FRA tokens
This function allows users to unstake (aka unbond) FRA tokens.
Parameters:​
- Â
<WalletKeypar>
- Wallet keypair - Â
<string>
- the amount users wants to unstake - Â
<string>
- validator's address - Â
<boolean>
- fully unstake option. Default isfalse
Results:​
- Â
Promise<TransactionBuilder>
- TransactionBuilder which should be used inTransaction.submitTransaction
.
Example:​
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);