-1

I'm running a simple smart contract on testrpc using remix:

Contract Testing{
    address [] public adds;
    uint [] public amounts;

    function bet() public payable{
        adds.push(msg.sender);
        amounts.push(msg.value);
    }

    function give() public {
        adds[0].transfer(amounts[0]);
    }
}

I first call bet() with a value of 1 ether from remix. I made sure that the funds of the contract were updated by checking this.balance. I then call give() from remix and I get the following error: transact to Betting.distributePrizes errored: VM Exception while processing transaction: out of gas. Is this just a bug in remix? Is it my contract?

EDIT: I'm still getting the same error even after copy-pasting nyusternie's code. Here is a picture after running give(): pic.

1 Answer 1

0

Its working fine for me in Remix. Here is the the exact code:

pragma solidity ^0.4.18;

contract Testing{
    address [] public adds;
    uint [] public amounts;

    function bet() public payable {
        adds.push(msg.sender);
        amounts.push(msg.value);
    }

    function give() public {
        adds[0].transfer(amounts[0]);
    }
}

And here is a link to an EthFiddle if you want to play in a test environment. https://ethfiddle.com/uFVTK81R37

2
  • I copy pasted your code into a new contract on remix and I get the same error before. However, when I run the code form my Javascript console, it works fine. Do you know what the problem may be here's a picture?
    – BeepBoop
    Jul 26, 2018 at 20:40
  • Are you using a "custom" web3 provider? If so, try publishing to one of the public testnets (eg Ropsten) and try again and/or post the contract hash if you still have problems.
    – Shomari
    Jul 27, 2018 at 14:08

Your Answer

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

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