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
Example
const AVN_API = require("avn-api");
const AVN_GATEWAY_URL = "<endpoint_url>"; //Replace the endpoint_url with the url received from Aventus.
const API = new AVN_API(AVN_GATEWAY_URL);
// Please, request the address or public key from Aventus.
const AVN_RELAYER = "5Fb...yTh";
// This can be the address or public key.
const RECIPIENT_ADDRESS = "5DA...gxV";
// The token address on Ethereum.
const TOKEN_CONTRACT_ADDRESS = "0x2a...b0e";
//amount of the token in 18 decimals.
const TOKEN_AMOUNT = "123400000";
async function main() {
await API.init();
let result = await API.send.transferToken(
AVN_RELAYER,
RECIPIENT_ADDRESS,
TOKEN_CONTRACT_ADDRESS,
TOKEN_AMOUNT
);
// Returns a request id
console.log(result);
}
(async () => {
await main();
})();
You have now successfully submitted a transaction to the AVN.
Example Result
f1710fe7-141f-43c1-b1bb-6ec33d9b3e9a
tip
You can query the state of your transaction here using the returned result.
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.
- 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 token being checked.
- amount [required] - a string integer value representing the amount (in lowest fraction) being transferred.
- 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":"proxyTokenTransfer", "params":{"relayer":"5FbU...ryTh", "user":"5DAg...JDdMr", "payer":"5DAg...JDdMr", "recipient":"5Fg...gqosF", 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 Output
{
"jsonrpc": "2.0",
"id": 1,
"result": "8b62441c-e032-46e3-bd1d-0f8a0a764442"
}