3

I have created a contract and contract is successfully deployed. I can see it on 'https://rinkeby.etherscan.io/'
While accessing its ABI using web3 and paying money using meta mask

Smart contract code is

pragma solidity ^0.4.17;

contract mypool{
    address public manager;
    string poolname;
    uint256 poolEndDate;
    uint256 poolAmount;

    constructor () public {
        manager = msg.sender;
    }

    struct Payer {
        string name;
        address player;
        uint256 amount;
    }

    Payer[] public players;

    function enterPoolInfo(string name,uint256 endDate, uint256 amount) public {
        poolname = name;
        poolEndDate = endDate;
        poolAmount = amount;
    }

    function enter(string name,uint256 amount) public payable {
        require(msg.value > .01 ether);

        Payer memory m;
        // players.push(Payer{player:msg.sender,amount:amount});
        m.player = msg.sender;
        m.amount = amount;
        m.name = name;
        players.push(m);
    }

}

I got the following error

index.js:368 Uncaught (in promise) Error: Transaction has been reverted by the EVM:
{
  "blockHash": "0x9695b98f4e55b98103bb1282dfffbcbddac03002b1199789ea0f027b1baee09f",
  "blockNumber": 2775473,
  "contractAddress": null,
  "cumulativeGasUsed": 1755656,
  "from": "0xdc091bc86e95ae492cdd67abf051e7c7e3432d70",
  "gasUsed": 24017,
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "status": false,
  "to": "0xe0ef5f6d4b4f75f66bb96713c17549c1ded4af98",
  "transactionHash": "0xaed58f7d6c230f41b30c2d6f45e057e4d63188fa1542540767ee90aa9f567ba8",
  "transactionIndex": 18,
  "events": {}
}
  • 1
    What is the code for the contract? – Raghav Sood Aug 8 '18 at 6:08
  • I have edit my post, Please check – Hussain Chauhan Aug 8 '18 at 6:50
3

The problem here is the amount of Ether you are sending as a part of your request.

In your code you have the following line:

require(msg.value > .01 ether);

This means you must send a minimum of .01 ETH to the contract, or it will revert like you are seeing.

Taking you transaction hash, and looking up the transaction on Etherscan:

https://rinkeby.etherscan.io/tx/0xaed58f7d6c230f41b30c2d6f45e057e4d63188fa1542540767ee90aa9f567ba8

We can see that you are only sending 100 wei to the contract when calling the function. You simply need to increase this to .01 ETH, and it should get past the revert error.

  • if i send more than one either , I am getting same error – Hussain Chauhan Aug 8 '18 at 7:09
  • You are calling the enter() function right? Can you show me a transaction where you send more than 1 ETH? I do not see any such transactions here. – Shawn Tabrizi Aug 8 '18 at 7:12
  • rinkeby.etherscan.io/address/… plese check – Hussain Chauhan Aug 8 '18 at 7:15
  • Increase your gas limit in this case. You can see your "gas limit" was 30000 and the "gas used by txn" was 30000, which means it ran out of gas before it could complete the operation. Gas limit should be above the gas used by the transaction, and any additional gas will be returned to the msg.sender. – Shawn Tabrizi Aug 8 '18 at 7:21

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.