I'm new user of Ethereum. My error :

Runtime Error: out of gas

My contract : https://github.com/cbourree/test/wiki

I compile with : https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.0+commit.acd334c9.js

"web3 deployed" generate with solidity : https://github.com/cbourree/test/wiki/Compiled-contract

I run testrpc -u 0 -u 1

On Chrome Console :

I run "web3 deployed" commandes
web3.fromWei(web3.eth.getBalance("0xafd05e5884d2cccc947b76da3e4af9025b677002"), "ether").toNumber(); //0xaf...002 address of my contract

WORK (return 10 Eth) ! But :

roulette.betEven(10, { from: web3.eth.accounts[1], value: web3.toWei(1, "ether") })

->Error : out of gas

The code comes from this tutorial : https://www.ethereum-france.com/ecrire-une-dapp-pour-ethereum-1-smart-contract/

Edit : I can execute the contract in truffle console without error


When i run

roulette.betOdd({ from: web3.eth.accounts[1] })


roulette.betOdd({ from: web3.eth.accounts[1], value: web3.toWei(10, "ether") })

I havn't error. But i don't understand why ???

  • Are you running the contract with the owner account?
    – Gawey
    Commented Apr 26, 2017 at 11:39
  • No, but i try also without succes :'( What is the time required for the contract to be accessible ? Because i don't know why but my old contract can run now Commented Apr 26, 2017 at 13:25

1 Answer 1


your code is unclear for me but I think the problem is generated by the modifier

modifier bankMustBeAbleToPayForBetType(BetType betType) {
    uint necessaryBalance = 0;
    for (uint i = 0; i < bets.length; i++) {
        necessaryBalance += getPayoutForType(bets[i].betType) * bets[i].value;
    necessaryBalance += getPayoutForType(betType) * msg.value;
    if (necessaryBalance > this.balance) throw;

maybe the (necessaryBalance > this.balance) check their values

  • Thanks for response but i try to unuse the modifier -> function betEven(uint number) public payable transactionMustContainEther() { Commented Apr 26, 2017 at 13:50
  • Why do you think it comes from the modifier? I tried to bypass the modifier, so not to use it in the code, but it still isn't working. Thanks for your help! Commented May 3, 2017 at 21:43
  • i ve only debugged it
    – Badr Bellaj
    Commented May 3, 2017 at 21:53

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.