I am trying to withdraw a contracts balance to the owner of that contracts account. It works perfectly on the JVM in solidity browser. But on TestRPC it has an out of gas exception.

The account has a lot of ether in it, more than enough to run the function to withdraw.

Any ideas why it only works on the JVM?


contract SinglePatreon { 
    bytes32 public name;
    uint public singleDonationAmount;
    uint public monthlyDonationAmount;
    address creator;
    uint contractNumber;

    modifier onlyCreator {if (msg.sender != creator) revert(); _; }
    modifier onlyPatreons {if (msg.sender == creator) revert(); _;}

    event LOG_SingleDonation (uint donationAmount, address donator);
    event LOG_Withdraw (uint emptyBalance);
    event LOG_creatorAddressAndSender (address factoryAddress, address creator);

    function SinglePatreon (bytes32 _name, uint _contractNumber) payable {        
        contractNumber = _contractNumber;
        PatreonFactory pf = PatreonFactory(msg.sender);
        name = _name;
        creator = pf.getOriginalCreator(contractNumber);
        LOG_creatorAddressAndSender(msg.sender, creator);


    function setOneTimeContribution(uint setAmountInWei) onlyCreator  returns(uint){
        singleDonationAmount = setAmountInWei;
        return singleDonationAmount;

      function oneTimeContribution() payable onlyPatreons returns(uint){
        if (msg.value != singleDonationAmount) revert(); 
        LOG_SingleDonation(this.balance, msg.sender);
        return this.balance;

    function creatorWithdrawFromContract() onlyCreator returns (uint) { //some reason it says oout of gas when i try to call this from creator .... hmmm
      //maybe it is beacuse the contract does not have any gas. and transferring takes a lot of gas. setOntTimeContribution works though!? i dont know :\

      return creator.balance;

Here is the error I am getting:

callback contain no result Error: Error: VM Exception while executing eth_estimateGas: out of gas
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:59880:17
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:88044:5
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:11863:9
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8423:16
    at replenish (/home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8943:25)
    at iterateeCallback (/home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8933:17)
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8908:16
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:11860:13
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:88040:9
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:73948:7
  • could you post your code and your testrpc command line params to reproduce the issue?
    – szerte
    Jul 26, 2017 at 6:56

1 Answer 1


Try to convert the gas value in testnet log from hex to decimal and put the value a little larger than that in gas_value in the function call.

contractInstance.customFunction.call(arguments, { from: account, gas: gas_value});

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .