0

This the error intercepted from my javascript, using web3.js

Error: Transaction has been reverted by the EVM:
    {
    "blockHash": "0xba0e277e390d8a455cf3634f6fe38fd1a0fb0c4dc673fdf2e383a12beb8237db",
    "blockNumber": 5838119,
    "contractAddress": null,
    "cumulativeGasUsed": 79499,
    "from": "0x8d8d315a5b1bb25e8c0b1566726454fcc11b3647",
    "gasUsed": 35463,
    "logs": [],
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "status": false,
    "to": "0x6474d5b92127ef04f30dac3f48626334d36ab489",
    "transactionHash": "0x5b36d00330a2603450fc076ed74ff96c28a5003f14641589bc8cf77f2dde6455",
    "transactionIndex": 2
}
at Object.TransactionError (C:\progetti\nterilizer\node_modules\web3-core-helpers\src\errors.js:63:21)
at Object.TransactionRevertedWithoutReasonError (C:\progetti\nterilizer\node_modules\web3-core-helpers\src\errors.js:75:21)
at C:\progetti\nterilizer\node_modules\web3-core-method\src\index.js:448:48
at process._tickCallback (internal/process/next_tick.js:68:7)

receipt:
{ 
    blockHash:
    '0xba0e277e390d8a455cf3634f6fe38fd1a0fb0c4dc673fdf2e383a12beb8237db',
    blockNumber: 5838119,
    contractAddress: null,
    cumulativeGasUsed: 79499,
    from: '0x8d8d315a5b1bb25e8c0b1566726454fcc11b3647',
    gasUsed: 35463,
    logs: [],
    logsBloom:
    '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
    status: false,
    to: '0x6474d5b92127ef04f30dac3f48626334d36ab489',
    transactionHash:
    '0x5b36d00330a2603450fc076ed74ff96c28a5003f14641589bc8cf77f2dde6455',
    transactionIndex: 2 
}

This is the test contract I am trying to execute

pragma solidity >=0.4.0 <0.6.0;

contract test013 {

    // These will be assigned at the construction
    // phase, where `msg.sender` is the account
    // creating this contract.
    address public owner = msg.sender;

    // record id => json
    mapping (uint256 => string ) private storedData;

    modifier isOwner() {    
        require(owner == msg.sender);
        _;
    }

    modifier dataNotStored(uint256 _index) {
        require( keccak256(abi.encodePacked(storedData[_index])) == keccak256(abi.encodePacked('')) );
        _;
    }

    function set(uint _index, string calldata _data_to_store) external dataNotStored(_index) {
        storedData[_index] = _data_to_store;
    }

    function forceSet(uint _index, string calldata _data_to_store) isOwner external {
        storedData[_index] = _data_to_store;
    }

    function get(uint _index) public view returns (string memory) {
        return storedData[_index];
    }
}

The failing function call is the set.

I am use that with the data I sent I am NOT hitting an already used mapping id.

It's mandatory for me to do not overwrite an entry to ensure data is writable once.

I have the dubt that I cannot send more than one transaction at time.... could it be the case?

  • What parameters are you providing to set? What transactions have you already submitted? In remix this seems to be working as you are intending. – Steven V Jan 22 at 18:22
1

Based on

The failing function call is the set

Two suspects:

Suspect ONE

require( keccak256(abi.encodePacked(storedData[_index])) == keccak256(abi.encodePacked('')) );

If I read that correctly, the requirement is the storedData == '', so possibly that isn't the case.

Suspect TWO

require(owner == msg.sender);

Check owner() and make sure that is your {from: <address>} when you call the function. 0x8d8d315a5b1bb25e8c0b1566726454fcc11b3647

RECOMMENDATION

This is very ambiguous:

pragma solidity >=0.4.0 <0.6.0;

Use a recent compiler and set that to the compiler you are actually using. A newer compiler let's you insert a revert reason that will help with debugging.

e.g.

require(false, "This message will output on the console if your client supports it.);"

Hope it helps.

| improve this answer | |
  • About "Use a recent compiler", In official doc I can see pragma solidity >=0.4.22 <0.7.0;. Is it anyway a bad practice? – realtebo Jan 24 at 13:50
0

After deconstruction both contract and js code, I ended discovering that I was sending a signedTransaction using web3.js using the 'gasLimit' in decimal instead of hex.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.