Web3js
呼叫 ERC-20 令牌 transfer() 方法時沒有任何反應
我目前正在使用版本 1.2.9 並使用 Infura Rinkeby 作為提供者。所以基本上我正在使用內置錢包建構一個節點應用程序。現在我已經成功創建了一個帳戶,並使用該帳戶通過簽署交易和發送交易將 ETH 交易發送到其他錢包。現在,當我必須在交易中發送合約方法時,我的程式碼認為我將 ETH 發送到該地址,我的程式碼是:
var contractAddress = account.asset[req.body.assetType].tokenAddress; var user_addressTo = req.body.toAccount; var amountSent = req.body.valusent; const myContract = new web3.eth.Contract(ABI,contractAddress); const result = { from: account.address, to:user_addressTo, value:0x00, gasPrice: web3.utils.toHex(web3.utils.toWei(gasPrice, 'gwei')), gas:req.body.gasLimit, data:myContract.methods.transfer(user_addressTo,amountSent).encodeABI() }; var signPromise = await web3.eth.accounts.signTransaction(result,key); var z = await web3.eth.sendSignedTransaction(signPromise.rawTransaction);
我已經多次檢查了我發送的值。每個值都工作得很好現在我從區塊鏈得到的響應是
blockNumber: 7645527, contractAddress: null, cumulativeGasUsed: 494263, from: '0xe6f2332b8758148de0e7739177544d28a4225807', gasUsed: 21620, logs: [], logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', status: true, to: '0x3dea86e3170ab1e93ff033cee4ae07bb19c75ab7', transactionHash: '0xca08aa4560de4bae21bceaa36ed2b8c23f218ca05cf7d9adad1845ac8b817dcc', transactionIndex: 2
我遵循了很多來自不同平台的教程和答案,但每個都給出了這個結果。你們能幫幫我嗎?
合約地址不包含任何智能合約程式碼:
https://rinkeby.etherscan.io/address/0x3dea86e3170ab1e93ff033cee4ae07bb19c75ab7
請先部署您的代幣智能合約,然後再使用其 ABI。