I have this simple code in remix.ethereum

pragma solidity ^0.6.1;

contract SimpleWallet {
    address owner;
    constructor() public {
        owner = msg.sender;
    modifier onlyOwner() {
        require(msg.sender == owner, "You are not allowed");

    function withdrawMoney(address payable _to, uint _amount) public onlyOwner {
    receive () external payable {

I try to deploy the contract with value of 10 eth in the js virtual machine using an address that has 100 eth

But I receive this

[vm]from:0xca3...a733cto:SimpleWallet.(constructor)value:10000000000000000000 weidata:0x608...c0033logs:0hash:0xc83...a1795
creation of SimpleWallet errored: VM error: revert.
revert  The transaction has been reverted to the initial state.
Note: The called function should be payable if you send value and the value you send should be less than your current balance.  Debug the transaction to get more information.

Why is that happening? The address has 100 eth, and the receive fallback function is defined, Shouldnt my contract be simply deployed with 10eth that way?

1 Answer 1


When you create a contract, it doesn't call a fallback. It calls the constructor. If you want to be able to send ETH with the creation of your contract, you need to mark the contructor as payable, like this:

constructor() public payable {
    owner = msg.sender;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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