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": {}
}
Best Answer
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:
This means you must send a minimum of
.01 ETH
to the contract, or it willrevert
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 therevert
error.