【问题标题】:Transfer trc20 usdt from one address to another将 trc20 usdt 从一个地址转移到另一个地址
【发布时间】:2021-03-24 16:15:36
【问题描述】:

我想为 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?

【问题讨论】:

  • 任何解决方案???

标签: tron tronweb


【解决方案1】:

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

转移 TRC20 不会激活帐户。但是可以通过地址向Tronscan查询余额。

TRON Account Documentation

【讨论】:

    猜你喜欢
    • 2021-11-17
    • 2018-09-24
    • 2017-12-10
    • 2015-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多