Skip to main content
Version: 2.4

Stake AVT

Stakes the specified amount of AVT, locking its free usage in order to earn rewards.

note

First time stakers must stake a minimum of 100 AVT.

await API.send.stake(AMOUNT_TO_STAKE)
important

This operation uses a relayer account that the sender authorizes to submit the transfer transaction. You can learn more about relayers HERE.

important

You can get the AVN_GATEWAY_URL and Relayer here.

const AVN_API = require("avn-api");
const AVN_GATEWAY_URL = "<node_url>";
const options = {
suri: "<account_suri>",
};
const API = new AVN_API(AVN_GATEWAY_URL, options);

//Amount of AVT in 18 decimals
const AMOUNT_TO_STAKE = '1000000000000000000';

async function main() {
await API.init();

let result = await API.send.stake(
AMOUNT_TO_STAKE
);
// Returns a request id
console.log(result);
}

(async () => {
await main();
})();

You have now successfully submitted a transaction to the AVN.

tip

You can query the state of your transaction here using the returned request id.

JSON-RPC

There are two JSON-RPC methods to staking AVT.

  1. proxyStakeAvt - Only to be used for first time stakers.
  2. proxyIncreaseStake Only to be used for current stakers.

"method":"proxyStakeAvt"

This should only be used for first time stakers - please query getStakingStatus to check first.

REQUEST
POST <https://AVN_GATEWAY_URL/send>

HEADERS
Content-Type: application/json Authorization': bearer <awtToken>

note

The initial staking requires 2 sets of proofs, one to cover the bonding step and one to cover the nominating step

REQUEST PARAMS

  • relayer [required] - a string representing the relayer's SS58 address
  • user [required] - a string representing the user's SS58 address
  • payer [required] - a string representing the payer's SS58 address
  • amount [required] - a string integer value representing the full amount of AVT to stake
  • targets [required] - The list of validators to nominate
  • nonce [required] - string integer value of the current proxy nonce of type 'staking'
  • proxySignature [required] - a proof signed by the user allowing the transaction to be proxied
  • feePaymentSignature [required] - a proof signed by the payer allowing the relayer fees to be paid
  • paymentNonce [required] - string integer value of the current payment nonce of the payer

JSON-RPC Example

curl https://AVN-API-URL/send \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: bearer <awtToken>" \
-d '{"jsonrpc":"2.0", "method":"proxyStakeAvt", "params":{"relayer": "5FbUQ...F3TeGyu6UoZaryTh",
"user": "5HMYezk4gRAoed...p7DGZM8rSTyf", "payer": "5HMYezk4gRAoed...p7DGZM8rSTyf",
"amount": "51000000000000000000", "targets": ["5CB8eZjJraPR7e...UHYUAG7HbnR", "5DHXA2pDmGM...zNw6EpBe9GgHKkunkL",
"5F6tYYDzZvGk...mUqSb3Q85nmkRa7JSMj", "5GNCn4Tyb3sgCF9...AZQWF1N1ikyVV",
"5HdTonR7WyEtwAR...1jzXXnzdgknViqiYyh"], "nonce": "112",
"proxySignature": "0x3c9d46239bb5426c9d253a2404c6444a12...7f055b93dd74ed9bb79a8ff10fe1343a4130602bdf32b2010b48d",
"feePaymentSignature": "0x82603b6dd7d63101a93db4402b57792443d1068...4ab61ff13ac81285bdc1304435a9338ade873bc84",
"paymentNonce": "10071"}, "id":1}'


Validation

This endpoint can only be called while the eraElectionWindow is closed. The status of the Election period can be checked here. If it is called during an election, the following error response will be returned:

{
"code":-32600,
"message":"Invalid Request",
"data": {
"gatewayError":"election window is open",
"request":"{...}"
}