0

I am using Remix with Metamask on the Ropsten test system, and when I try and transfer Wei I get a gas error. I tried a few combinations but there are various errors relating to gas.

Has anyone any example code for this?

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?

        address public mywallet = 0xcDDb122bb4dCe8AcF90078E0e853b1414d10EDb0;
        bool public status = false;

        function payUser (uint amount) public  payable returns (bool) {
          uint GAS_LIMIT = 4000000;
       //   userAddress.transfer.gas(GAS_LIMIT)(amount);
       //  status =  mywallet.call.value(amount).gas(GAS_LIMIT)();
         mywallet.transfer(amount);
         return status;
        }

        function getBalance(address walletAddress) public view returns (uint) {
            return walletAddress.balance;
        }

1 Answer 1

2

You'll need to fund the contract first. Otherwise if the contract has a balance of 0, when you call payUser with any value greater than 0, it will always fail.

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.