TRC-10转账

HTTP接口:

wallet/transferasset
作用:转账Token
demo:curl -X POST   https://127.0.0.1:8090/wallet/transferasset -d '{
  "owner_address":"41d1e7a6bc354106cb410e65ff8b181c600ff14292", 
  "to_address": "41e552f6487585c2b58bc2c9bb4492bc1f17132cd0", 
  "asset_name": "0x6173736574497373756531353330383934333132313538", 
  "amount": 100
}'
参数说明:
  owner_address是token转出地址,需要是hexString格式 
  to_address是token转入地址,需要是hexString格式 
  asset_name是token名称,需要是hexString格式
  amount是token转账数量  

返回值:token转账的Transaction

Tronweb示例:

const privateKey = "..."; 
var toAddress = "TM2TmqauSEiRf16CyFgzHV2BVxBejY9iyR";
var tokenID= "1000088";
var amount = 1000;
var fromAddress = "TVDGpn4hCSzJ5nkHPLetk8KQBtwaTppnkr";
//创建一个未签名的 TRC10 转账交易
tradeobj = await tronWeb.transactionBuilder.sendToken(
      toAddress,
      amount,
      tokenID,
      fromAddress,    
).then(output => {
  console.log('- Output:', output, '\n');
  return output;
});
//签名
const signedtxn = await tronWeb.trx.sign(
      tradeobj,
      privateKey
);
//广播
const receipt = await tronWeb.trx.sendRawTransaction(
      signedtxn
).then(output => {
  console.log('- Output:', output, '\n');
  return output;
});

Wallet-cli示例:

#用法:TransferAsset [OwnerAddress] ToAddress AssertID Amount
TransferAsset TWbcHNCYzqAGbrQteKnseKJdxfzBHyTfuh 1000099 1000

请按照以下说明步骤完成本次交易:
1.提示:“Please confirm and input your permission id, if input y or Y means default 0, other non-numeric characters will cancel transaction.”,输入“y” 或是“Y”, 确认本次交易;
2.提示:“lease choose your key for sign. …… Please choose between 1 and 2”,选择签名账户的序号;
3.提示:“Please input your password.”,输入本地密码;
4.提示:“TransferAsset 1000 to TWbcHNCYzqAGbrQteKnseKJdxfzBHyTfuh successful !!” ,表示转账TRC10代币成功。