Solidity:如何发送嵌套结构作为参数?

时间:2019-02-08 13:25:01

标签: solidity web3js


我正在尝试将嵌套结构发送到智能合约,但是交易会还原:

const person = {
  name: "Me",
  age: 24,
  car: {
    id: 1,
    color: "black"
}

myContract.methods.addPerson(person).send({from: "0x3b0282D31174B927e102bA71d80dF34F4e596Fc4", gas:300000}, (error, result) => {
                if (error) {
                    console.log(error);
                } else {
                    console.log(result);
                });

这总是抛出:

(node:17276) UnhandledPromiseRejectionWarning: Error: Transaction has been reverted by the EVM:
{
  "blockHash": "0x84647034828b4adf766a5bb55d19a32d665ba7e8c9cbcde4f2ecd8f3b112a13a",
  "blockNumber": 49378,
  "contractAddress": null,
  "cumulativeGasUsed": 300000,
  "from": "0x3b0282d31174b927e102ba71d80df34f4e596fc4",
  "gasUsed": 300000,
  "logsBloom": "0x000000000000000000000000000000000...",
  "status": false,
  "to": "0x37fe85f3a96a5fc1f9396ec42ae197d73a239ad7",
  "transactionHash": "0x43f0508b4419525b0eb4ab5a40765a3991ba152ba70c2731c6892d1253c9dfac",
  "transactionIndex": 0,
  "events": {}
}

如果我发送一个简单的结构,它将很好用

注意:我正在使用web3 1.0.0-beta.37

0 个答案:

没有答案