Unstake AVT
Unstakes the specified amount of AVT, removing it from earning further staking rewards and (after a period) allowing it to be withdrawn back to the free balance.
There is a minimum stake balance for an account to remain being considered a nominator. This is 10AVT. If the user's balance after unstaking falls below the minimum stake balance, the Gateway will unstake the entire stake balance in the same transaction.
await api.send.unstake(amountToUnstake);
- Example
- Example Result
- JSON-RPC
- JSON-RPC Output
const { AvnApi, SetupMode, SigningMode } = require("avn-api");
const AVN_GATEWAY_URL = "https://gateway.testnet.aventus.network";
const singleUserOptions = {
suri: "0x5392ca60a61aea99fce14358798de93c1bc11c3696a905718738c71fae539c24", // this is from the generated example account
setupMode: SetupMode.SingleUser,
signingMode: SigningMode.SuriBased,
};
const avnSdk = new AvnApi(AVN_GATEWAY_URL, singleUserOptions);
//This can be an address or public key.
const RECIPIENT_ADDRESS = "5DA...gxV";
//Amount of AVT in 18 decimals
var amountToUnstake = "500000000000000000";
async function main() {
await avnSdk.init();
const api = await avnSdk.apis();
let result = await api.send.unstake(amountToUnstake);
// Returns a request id
console.log(result);
}
(async () => {
await main();
})();
You have now successfully submitted a transaction to the AVN.
f1710fe7-141f-43c1-b1bb-6ec33d9b3e9a
REQUEST
POST <https://AVN_GATEWAY_URL/send>
HEADERS
Content-Type: application/json Authorization: bearer <awtToken>
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 unstake.
- 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 user allowing the relayer fees to be paid.
- paymentNonce [required] - string integer value of the current account payment nonce.
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":"proxyUnstakeAvt", "params":{"relayer":"5FbUQ2kJWLoqHuSTSN...Gyu6UoZaryTh", "user":"5DAgxVxKmnJ...JZjirSVJDdMr", "payer":"5DAgxVxKmnJ...JZjirSVJDdMr", "amount":"1000000000000000000", "nonce":"10", "proxySignature":"0x58fb48fdc865c557d9b6135f...248167bcffbdbeaa9f1eb9b03d6aea0260ea6a941b0b168f9a1e3729ee3a4e94e8088", "feePaymentSignature":"0x5a1538a4931d310ad948db35...b906aaaea6632810f4c1cd25a81218463a5550efa53229f8b4e033aaf476a5e72c881", "paymentNonce": "779"}, "id":1}'
result - a request ID that can be queried for the transaction's status
{
"jsonrpc": "2.0",
"id": 1,
"result": "8f7f76c8-a06e-11ec-b909-0242ac120002"
}
You can query the state of your transaction here using the returned request id.
Validation
This endpoint can only be called while the eraElectionWindow
is closed. 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":"{...}"
}