Transfer AVT
Transfer an amount of AVT from the sender account to the destination account.
await api.send.transferAvt(recipientAddress, amount);
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);
//This can be an address or public key.
const RECIPIENT_ADDRESS = "5DA...gxV";
//Amount of AVT in 18 decimals
const AMOUNT = "123400000";
async function main() {
await api.init();
const result = await api.send.transferAvt(
RECIPIENT_ADDRESS,
AMOUNT
);
// Returns a request id
console.log(result);
}
(async () => {
await main();
})();
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
- recipient [required] - a string representing the recipient's SS58 address
- token [required] - a hex string representing the token ID (20 bytes) of the AVT contract
- amount [required] - a string integer value representing the amount (in atto AVT) being transferred
- nonce [required] - string integer value of the current proxy nonce of type 'token'
- 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":"proxyAvtTransfer", "params":{"relayer":"5FbUQ2kJ...3TeGyu6UoZaryTh", "user":"5DAgxVxKmn...VJDdMr", "payer":"5DAgxVxKmn...VJDdMr", "recipient":"5FgyNN84CzQfwHBUJWvQkr36hiQYEXjDhcUYVx9tCTdgqosF", "token":"0x405df1b38510c455ef81500a3dc7e9ae599e18f6", "amount":"20000", "nonce":"10", "proxySignature":"0xc2f5deeede546...d5a949e90027eed2a19f2a12161c293204dbb1ccc4032e4248760f6385a83d5e44188cf9d8b", "feePaymentSignature":"0xde49e7ab0...1357076918ca78465a5428f77507f966531e29eee43070611d07f5a1632c11ff1741c3c12b22db83", "paymentNonce":"200"}, "id":1}'
note
result - a request ID that can be queried for the transaction's status
{
"jsonrpc": "2.0",
"id": 1,
"result": "540aef9d-5798-41c0-8f43-a6eb3986a3e0"
}
You have now successfully submitted a transaction to the AVN.
tip
You can query the state of your transaction here using the returned result.