TRC10 Transfer
HTTP API:
wallet/transferasset
Description: Transfer token
demo: curl -X POST http://127.0.0.1:8090/wallet/transferasset -d '{"owner_address":"41d1e7a6bc354106cb410e65ff8b181c600ff14292", "to_address": "41e552f6487585c2b58bc2c9bb4492bc1f17132cd0", "asset_name": "31303030303031", "amount": 100}'
Parameter owner_address: Owner address, default hexString
Parameter to_address: To address, default hexString
Parameter asset_name: Token id, default hexString
Parameter amount: Token transfer amount
Parameter permission_id: Optional, for multi-signature use
Return: Transaction object
Note: The unit of 'amount' is the smallest unit of the token
Tronweb Example:
const privateKey = "...";
var toAddress = "TM2TmqauSEiRf16CyFgzHV2BVxBejY9iyR";
var tokenID= "1000088";
var amount = 1000;
var fromAddress = "TVDGpn4hCSzJ5nkHPLetk8KQBtwaTppnkr";
//Creates an unsigned TRC10 token transfer transaction
tradeobj = await tronWeb.transactionBuilder.purchaseToken(
toAddress,
amount,
tokenID,
fromAddress,
).then(output => {console.log('- Output:', output, '\n');});
//sign
const signedtxn = await tronWeb.trx.sign(
tradeobj,
privateKey
);
//broadcast
const receipt = await tronWeb.trx.sendRawTransaction(
signedtxn
).then(output => {console.log('- Output:', output, '\n');});
Wallet-cli Example :
#Usage : TransferAsset [OwnerAddress] ToAddress AssertID Amount
TransferAsset TWbcHNCYzqAGbrQteKnseKJdxfzBHyTfuh 1000099 1000
Please follow the instructions below to complete this transaction:
- Tip: "Please confirm and enter your permission id, if input y or Y means default 0, other non-numeric characters will cancel transaction.", Enter "y" or "Y" to confirm the transaction;
- Tip: "lease choose your key for sign. ...... Please choose between 1 and 2", select the serial number of the sign account;
- Tip: "Please input your password.", Enter your local password;
- Tip: "TransferAsset 1000 to TWbcHNCYzqAGbrQteKnseKJdxfzBHyTfuh successful !!", which indicates that Successfully transferred TRC10 tokens.
Updated almost 5 years ago