4

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

EDIT 2

When i run

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

then

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 Apr 26 '17 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 – Charles Bourrée Apr 26 '17 at 13:25
2

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() { – Charles Bourrée Apr 26 '17 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! – Charles Bourrée May 3 '17 at 21:43
  • i ve only debugged it – Badr Bellaj May 3 '17 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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