我想为 usdt 支付构建一个网关,为此我使用 Tronweb tronWeb.utils.accounts.generateAccount() 方法 我已经生成了一个地址,向它转移了 1 美元,现在我想将资金转移到另一个地址。 发送交易时出现错误:
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?
答案 0 :(得分:0)
新账户生成后,需要通过转账TRX/TRC-10代币到地址激活。
<块引用>转移 TRC20 不会激活帐户。但是可以通过地址向Tronscan查询余额。