q9f / eth.rb

a straightforward library to build, sign, and broadcast ethereum transactions anywhere you can run ruby.
https://q9f.github.io/eth.rb
Apache License 2.0
196 stars 85 forks source link

eth call contract function get error IOError: execution reverted #263

Closed Sylor-huang closed 3 months ago

Sylor-huang commented 5 months ago

Codes:

client = Eth::Client.create('rpc')
abi = [
            {
                "inputs": [
                    {"internalType": "uint256", "name": "deadline", "type": "uint256"},
                    {"internalType": "bytes32", "name": "attributeHash", "type": "bytes32"},
                    {"internalType": "bytes", "name": "signature", "type": "bytes"}
                ],
                "name": "mintSBT",
                "outputs": [],
                "stateMutability": "nonpayable",
                "type": "function"
            }
        ]

sbt_contract = Eth::Contract.from_abi(name: "SBTs", address: 'xxx', abi: abi)

# res_data includes deadline, attributeHash, signature

res  = client.call(sbt_contract, "mintSBT", res_data["deadline"].to_i, res_data["attributeHash"].to_s, res_data["signature"].to_s, sender_key: 'wallet private key')

client.call get error: IOError: execution reverted

Please help, thanks.

Sylor-huang commented 5 months ago

@q9f please help, thanks.

q9f commented 3 months ago

execution reverted means that your ruby code is good but your contract execution failed on the evm.

to debug this, we would need to know more details about your transaction.

see https://metana.io/blog/evm-execution-reverted-errors