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 { 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);
const RECIPIENT_ADDRESS = "replace with recipient's address"
const amount = "123400000"; // the integer wei value of the amount. Decimals (e.g. 2.4) are not supported.
async function main() {
await avnSdk.init();
const api = await avnSdk.apis();
const request_id = await api.send.transferAvt(RECIPIENT_ADDRESS, amount));
console.log(request_id)
}
(async () => {
await main();
})();
Response: 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.