Withdraw Unstaked AVT
Withdraws previously unstaked AVT back to the user's free balance.
await api.send.withdrawUnlocked()
important
- Example
- Example Result
- JSON-RPC
- JSON-RPC Output
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);
async function main() {
await api.init();
let result = await api.send.withdrawUnlocked();
// 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/query>
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
- nominator [required] - a string representing the nominator's SS58 address
- 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":"proxyWithdrawUnlocked", "params":{"relayer": "5FbUQ2kJWLoq...yu6UoZaryTh",
"user": "5HMYezk4gR...8XQp7DGZM8rSTyf", "payer": "5HMYezk4gR...8XQp7DGZM8rSTyf",
"nominator": "5HMYezk4gR...8XQp7DGZM8rSTyf", "nonce": "115",
"proxySignature": "0x8ad565c42f4ba4ed64a03cda...455637d4134c4264c1cc8fe38509fbf9474af9dd2721f1a64df944c1ffd6ad167a0784",
"feePaymentSignature": "0x2494c0c4ebf6bc61785e37cea...675b1c987a1cea36b6f3cae1bb9e636c931e7f119f71408f9e7bc3b20fd088",
"paymentNonce": "10074"}, "id":1}'
result - a request ID that can be queried for the transaction's status
{
"jsonrpc": "2.0",
"id": 1,
"result": "7fd01739-2a52-4eba-941a-00497e7e0bf0"
}
tip
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. 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":"{...}"
}