代码之家  ›  专栏  ›  技术社区  ›  maroodb

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

  •  0
  • maroodb  · 技术社区  · 7 年前


    我试图向智能合约发送嵌套结构,但事务恢复:

    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 回复  |  直到 7 年前