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 ofDelegateInfoDataResultcontaining 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 ofvalidatorListResponsecontaining 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);