4

I'm making this call from JavaScript to the contract function.

contracts['CrowdFunder'].contract.contribute({value: web3.toWei(0.000000000000000005, 'ether')});

The function is called, but the error message says,

An error occurred during contract execution: 'Out of gas'

See http://testnet.etherscan.io/vmtrace?txhash=0x58c3e7d41db0dd3ba4c2b600b374b2576f9508d84e7351058232027af4cc3abb

How do I specify the amount of gas in JavaScript for the above?

6

Try changing

contracts['CrowdFunder'].contract.contribute({
    value: web3.toWei(0.000000000000000005, 'ether')
});

to

contracts['CrowdFunder'].contract.contribute({
    value: web3.toWei(0.000000000000000005, 'ether'), 
    gas: 100000 
});

Refer to the example under Contract Methods in JavaScript API - web3.eth.contract.

And modifying the call as suggested by eth's comment below:

contracts['CrowdFunder'].contract.contribute({
    value: 5, 
    gas: 100000 
});
  • 2
    Also, OP since you only want to pass 5 wei, just use value: 5. – eth Apr 17 '16 at 3:55

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.