1
votes

Tried to create a simple wallet with a fallback function but still
VM error: revert. Note: The constructor should be payable if you send value. Why?

pragma solidity ^0.4.0;
contract MyWallet
  {
      struct account
       {
        uint balance;
        uint dailyLimit;
       }

      mapping (address =>account) _accounts;
      //created  this fallback payable function
    function () payable {
         _accounts[msg.sender].balance+=msg.value;
       }  

      //to get balance
    function getBalance() returns (uint){
        return _accounts[msg.sender].balance;
       }

 }
1
You should explain your question in more detail, to allow other users to help you. - mattmilten

1 Answers

1
votes

You get this error because you're trying to call an explicit function that isn't payable. The error message will occur if you send ether during deployment and there is no payable on the contstructor, or if you initiate a transaction through a defined function that isn't marked as payable. To trigger the fallback function, you would send a transaction in which the data field (which describes what will be invoked) is empty.