第一步:获取个人波场钱包地址
linkWallet(){
if(window.tronWeb){
this.tronWeb = window.tronWeb;
this.walletAddress = window.tronWeb.defaultAddress.base58;
}else{
alert('请切换至波场钱包')
}
},
第二步:发起转账交易
async transactionToken() {
let toAddress = 'TBaka7KwzDWasyLutEaebHm6b4Bw3sGmJz';// 转账收款地址
let amount = 10;
let contract = await window.tronWeb.contract().at('TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t'); // TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6tUSDT合约地址
let result = await contract.transfer(
toAddress, // 转账地址 toAddress
window.tronWeb.toHex(amount * Math.pow(10,18))
).send({
feeLimit: 10000000
}).then(output => {
console.log('-交易hash:', output, '\n');
}).catch(err=>{
console.log('支付取消或者失败')
});
},
一次转账交易完成
网友评论