gpt4 book ai didi

tron - 将 trc20 usdt 从一个地址转移到另一个地址

转载 作者:行者123 更新时间:2023-12-05 03:43:29 43 4
gpt4 key购买 nike

我想为 usdt 支付构建一个网关,为此我正在使用 Tronweb tronWeb.utils.accounts.generateAccount() 方法我已经生成了一个地址,将 1 usdt 转入该地址,现在我想将资金转入另一个地址。发送交易时出现错误:

  error: 'CONTRACT_VALIDATE_ERROR',
message: 'contract validate error : account does not exist'


This is my code:

const TronWeb = require('tronweb');
const HttpProvider = TronWeb.providers.HttpProvider;
const fullNode = new HttpProvider("https://api.trongrid.io");
const solidityNode = new HttpProvider("https://api.trongrid.io");
const eventServer = new HttpProvider("https://api.trongrid.io");
const privateKey = "c83f36ae2e8661170e798ca73181693b76d75af016666e6f6baad92f69cfa1e2";
const tronWeb = new TronWeb(fullNode, solidityNode, eventServer, privateKey);
const trc20ContractAddress = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t";//contract address
const addressTo = "TYcDSZor5ZgTsVMCZe1czfPEu8kzn6qe7L";
async function transfer() {
try {
const ownerAddress = tronWeb.address.fromPrivateKey(privateKey);
const contractAddressHex = tronWeb.address.toHex(trc20ContractAddress);
const contractInstance = await tronWeb.contract().at(contractAddressHex);
const decimals = await contractInstance.decimals().call();
const amount = 7 * Math.pow(10, decimals);
const response = await contractInstance.transfer(addressTo, amount).send();
console.log(response);
} catch (e) {
console.error(e);
return null;`enter code here`
}
}
transfer();


Is it something else i should do for getting this to work?

最佳答案

生成新账户后,您需要将TRX/TRC-10代币转入地址激活。

Transferring TRC20 will not activate an account. However, the balance can be inquired from Tronscan by the address.

TRON Account Documentation

关于tron - 将 trc20 usdt 从一个地址转移到另一个地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66785117/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com