pwasm-ethereum icon indicating copy to clipboard operation
pwasm-ethereum copied to clipboard

pwasm-ethereum::balance causes revert

Open COLD-PLAY opened this issue 5 years ago • 1 comments

I write a contract and used the function pwasm-ethereum::balance(&Address), but when I deployed this contract on private chain and use web3.js call this contract, error happened: "Error: Transaction has been reverted by the EVM:".

The contract's function code is followed:

fn balance_test(&mut self) -> U256 {
    let _balance = pwasm_ethereum::balance(&Address::from([
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
    ])); // should return 0
    _balance
}

COLD-PLAY avatar Nov 17 '20 11:11 COLD-PLAY

The error details is:

Error: Transaction has been reverted by the EVM:
{
  "blockHash": "0x709fda93502cddd34af80121d8b63253f6200d866419e2d5d8f948313de3f0af",
  "blockNumber": 2,
  "contractAddress": null,
  "cumulativeGasUsed": 400000,
  "from": "0x004ec07d2329997267ec62b4166639513386f32e",
  "gasUsed": 400000,
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "status": false,
  "to": "0xedfc9c2f4cfa7495c1a95cfe1cb856f5980d5e18",
  "transactionHash": "0xbf8b775195312082506100ca6f0b943e3394af36ccb8bd676ce02c7c9f0b78a5",
  "transactionIndex": 0,
  "events": {}
}
    at Object.TransactionError (/home/coldplay/node_modules/web3-core-helpers/lib/errors.js:87:21)
    at Object.TransactionRevertedWithoutReasonError (/home/coldplay/node_modules/web3-core-helpers/lib/errors.js:98:21)
    at /home/coldplay/node_modules/web3-core-method/lib/index.js:394:57
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  receipt: {
    blockHash: '0x709fda93502cddd34af80121d8b63253f6200d866419e2d5d8f948313de3f0af',
    blockNumber: 2,
    contractAddress: null,
    cumulativeGasUsed: 400000,
    from: '0x004ec07d2329997267ec62b4166639513386f32e',
    gasUsed: 400000,
    logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
    status: false,
    to: '0xedfc9c2f4cfa7495c1a95cfe1cb856f5980d5e18',
    transactionHash: '0xbf8b775195312082506100ca6f0b943e3394af36ccb8bd676ce02c7c9f0b78a5',
    transactionIndex: 0,
    events: {}
  }
}

The launch openethereum command is:

./oeth --chain openethereum.json --base-path ./data --jsonrpc-apis=all --jsonrpc-cors https://remix.ethereum.org --logging=warn

COLD-PLAY avatar Nov 17 '20 11:11 COLD-PLAY