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 {
_to.transfer(_amount);
}
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?