Skip to main content
Version: 0.5

Transfer Token

Transfer an amount of ERC20 or ERC777 token from the sender account to the recipient account.

await api.send.transferToken(
avnRelayerAddress,
recipientAddress,
tokenContractAddress,
amount
);
info

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

Contact us here to request a relayer address.

Example

const AvnApi = require("avn-api");
const GATEWAY = "<endpoint_url>"; //Replace the endpoint_url with the url received from Aventus.
const api = new AvnApi(GATEWAY);

const avnRelayerAddress = "5Fb...yTh"; //Please, request from Aventus.
const recipientAddress = "5DA...gxV";
const tokenContractAddress = "0x2a...b0e";
const amount = "123400000";

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

const result = await api.send.transferToken(
avnRelayerAddress,
recipientAddress,
tokenContractAddress,
amount
);
// Returns a request id
console.log(result);
}

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

You have now successfully submitted a transaction to the AVN.

Example Output

f1710fe7-141f-43c1-b1bb-6ec33d9b3e9a

JSON-RPC

Transfers the specified amount of an ERC20 or ERC777 token, from the sender account to the destination account, using a relayer account

REQUEST POST https://AVN-API-URL/send

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

REQUEST PARAMS relayer [required] - a string representing the relayer's SS58 address
signer [required] - a string representing the sender'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 token being checked
amount [required] - a string integer value representing the amount (in lowest fraction) of the token being transferred
proxySignature [required] - a proof signed by the sender/signer account allowing the transaction to be proxied
feePaymentSignature [required] - a proof signed by the sender/signer account allowing the relayer fees to be paid
paymentNonce [required] - string integer value of the current account payment nonce

Example

curl https://AVN-API-URL/send \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: bearer <awtToken>" \
-d '{"jsonrpc":"2.0", "method":"proxyTokenTransfer", "params":{"relayer":"5FbUQ2kJWLoqHuSTSNNqBwKwdQnBVe4HF3TeGyu6UoZaryTh", "signer":"5DAgxVxKmnJ7hfhDEB9UetZm4jR2MPjGZGrmJZjirSVJDdMr", "recipient":"5FgyNN84CzQfwHBUJWvQkr36hiQYEXjDhcUYVx9tCTdgqosF", "token":"0xb130395ae89acbe32999f8eb6e6114a56d676199", "amount":"1000000", "proxySignature":"0x883e4300581dcaf3373c81eff1ec86776c58aa12fd184d4500d1aab8b7832076484d967ca01c96e7ab6d20903145c9efebac38ed521f30fe52da2e27beecf08f", "feePaymentSignature":"0x7cff997be6fb98db949da0eceee2480b46a3b3aeaf4dbc7862bf6617a4c23319f666dfc2bb9e9a365ffd67ab279d980a0139fa6ce0165cdd76aaf555e7a1ba80", "paymentNonce":"199"}, "id":1'
note

result 👇🏽 - a request ID that can be queried for the transaction's status.

Example Result

{
"jsonrpc": "2.0",
"id": 1,
"result": "8b62441c-e032-46e3-bd1d-0f8a0a764442"
}

Query Transaction State

tip

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