So I have a simple smart contract (shown below).

// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

contract Casino {
    function pay() external payable{

    function getContractBalance() public view returns (uint256 balance){
       return address(this).balance;

    function getContractAddress() public view returns(address){
           return address(this);

    receive() external payable{

What I want to do:

Send ether to Casino smart contract.

My issue:

I've been using web3js to interact with my smart contract. From there, I call:

await web3.eth.sendTransaction({from: sender, to: CasinoContractAddress, value: someValue})

What happens is metamask opens and I can submit the payment. But in the end, the transaction fails and I get this error in console:

Error: Transaction has been reverted by the EVM:
  "blockHash": "0x53b67f247f1fb81265767bcf3d6987c7cdfd230dad2fe3e7d79fa67c1ba9dd1e",
  "blockNumber": 9715752,
  "contractAddress": null,
  "cumulativeGasUsed": 54114,
  "from": "0xc106b46180d0ad4e5302e7ccb9485c819adc3fff",
  "gasUsed": 21045,
  "logs": [],
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "status": false,
  "to": "0xdc1812ae654aa8556d64b300c0527541f911b797",
  "transactionHash": "0x4373e277493fa4f478ffd2a929c7023e463bfbd2cdf3b520abc3b230b0f6de21",
  "transactionIndex": 1
    at Object.TransactionError (errors.js:87)
    at Object.TransactionRevertedWithoutReasonError (errors.js:98)
    at index.js:394

I'm stumped on this issue and would really appreciate some help. Thanks!

  • I tried the same contract compiled with solc 0.7.6 and it works as expected. Also the gas used is very little 21045, it may means it failed at the very beginning, so perhaps you forgot a payable and deployed a previous version. – Ismael Feb 23 at 3:47

Your Answer

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

Browse other questions tagged or ask your own question.