15 JS通过ABI调用合约函数出错,请帮看看,谢谢

合约里代码:

function multisend(address _tokenAddr, address[] dests, uint256[] values) public onlyOwner returns (uint256) {
uint256 i = 0;
while (i < dests.length) {
ERC20(_tokenAddr).transferFrom(msg.sender, dests[i], values[i]);
i += 1;
}
return(i);
}

JS里调用代码:

adcontract.methods.multisend(caddress,addressarr, adnumbers).send({ from: laddress })

出错信息:

web3.min.js:15 Uncaught (in promise) Error: Transaction has been reverted by the EVM:
{
"blockHash": "0x525e310cece9502ad5487b4f14ef5f805675ecb5e2c9ffc82529fd275c85a0c2",
"blockNumber": 6827257,
"contractAddress": null,
"cumulativeGasUsed": "1344216",
"from": "0x59970127947d1c089a4dc2e4edbe3f79cf9a2803",
"gasUsed": "32616",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status": false,
"to": "0x270e00ae06e8d1738f20b5fe9bfa792e455d7803",
"transactionHash": "0x33d77641d991e01450a878454bbf19d6b318a1e6ae3b7ea0b70c11e799b138db",
"transactionIndex": 8,
"events": {}
}
请先 登录 后评论

最佳答案 2021-07-27 17:50

我在heco上找到了你的交易,https://hecoinfo.com/tx/0x33d77641d991e01450a878454bbf19d6b318a1e6ae3b7ea0b70c11e799b138db,交易数据为

MethodID: 0xad8733ca
[0]:  0000000000000000000000007f28616c97e0de533973fbc912055850174662ee
[1]:  0000000000000000000000000000000000000000000000000000000000000060
[2]:  0000000000000000000000000000000000000000000000000000000000000320
[3]:  0000000000000000000000000000000000000000000000000000000000000015
[4]:  000000000000000000000000981665a523f648ea12f04a200d91d888aaebebc9
[5]:  000000000000000000000000dd588bad4a6943a73a23060a02db013597068c41
[6]:  000000000000000000000000d5ba42a922a715751018cb92d7c3f8165ca61a3d
[7]:  000000000000000000000000dda50616f204650acf7cb1d4d1d5b94a9bca3e37
[8]:  000000000000000000000000b4dcd17668118df8962f8a4f2d74016faff4a80f
[9]:  000000000000000000000000ddc68071dd05fcc50fa811177f8bd28e9ba9f22f
[10]: 000000000000000000000000de02368e7667b99b871f73cee78f66dbefe77609
[11]: 000000000000000000000000371cfbe189074b88cfe9b5583d40d89e026a3e69
[12]: 0000000000000000000000006b98bd4f44457eb48c596c4f8377c0a08e6a9b06
[13]: 000000000000000000000000b710b725635de438c68615f018292d1ea4a1297b
[14]: 000000000000000000000000df72974be7edd568c3a4c27260b120e10fe9174c
[15]: 000000000000000000000000997c64bbf79c4154a2b9b2c122510db6428e1f14
[16]: 000000000000000000000000015dc85445d22229c862080d86fa2d45bbd5fa6f
[17]: 000000000000000000000000df8c75cfd75a48e99fad91641d04230ae2a22a5d
[18]: 000000000000000000000000dfdfbc0fd2eefe05f941e3b1298211244e69fd4d
[19]: 000000000000000000000000c7fcf46781a57014ec04cbfa01367308505c6efa
[20]: 000000000000000000000000095246012200acf4ea4dbc3638ad33a48d6ed641
[21]: 000000000000000000000000e00a151805069d77041abe43e71e77933c6da946
[22]: 0000000000000000000000009e69ad4b1d439d6a561a4f1c85f5d0bcff7f3d5d
[23]: 000000000000000000000000e00eec5563aee93577f8ae5d08fb8567fe741502
[24]: 0000000000000000000000006270be52492bef858474d40aa313c5ee8cbd7e50
[25]: 0000000000000000000000000000000000000000000000000000000000000009
[26]: 0000000000000000000000000000000000000000000000000000000000000001
[27]: 0000000000000000000000000000000000000000000000000000000000000001
[28]: 0000000000000000000000000000000000000000000000000000000000000001
[29]: 0000000000000000000000000000000000000000000000000000000000000001
[30]: 0000000000000000000000000000000000000000000000000000000000000001
[31]: 0000000000000000000000000000000000000000000000000000000000000001
[32]: 0000000000000000000000000000000000000000000000000000000000000001
[33]: 0000000000000000000000000000000000000000000000000000000000000001
[34]: 0000000000000000000000000000000000000000000000000000000000000001

[3]对应的数值代表的是dests的长度为0x15,[25]对应的数值为0x09是values的长度,这两个你传入的长度并不相等

合约在执行

ERC20(_tokenAddr).transferFrom(msg.sender, dests[i], values[i]);

的时候肯定是会报错的,values数组越界

请先 登录 后评论

其它 2 个回答

carvin
请先 登录 后评论
carvin
请先 登录 后评论
  • 2 关注
  • 0 收藏,389 浏览
  • carvin 提出于 2021-07-27 17:26