0

I am trying to test executing a method on an existing contract, but the transaction keeps running out of gas, and I can't figure out why. I am trying to call an Etheroll contract on the Rinkeby test network. (etheroll)

I am running a Geth node attached to the Rinkeby network and the node is fully synced and has an account with Ethereum in it (account) I am using web3 over a WS connection to this test Geth node. This is the code for the latest transaction I tried:

let abiObj = [.....]; // ABI object obtained from Rinkeby blockchain explorer
let myContract = new conSce.web3.eth.Contract(abiObj, '0xf5e8c6a9F35E79B7A632fD7A9FE4A1f0D5021837')

myContract.methods['playerRollDice(uint256)'](90).send({ from: "0x25921ee056a5add0c4952d8c060944afeba470b9", value: '200500000000000000', gasPrice: '2000000000', gas: '5000000' }).then(receipt => console.log(receipt)).catch(err => console.log(err))

When running this, it returns the following error, along with the transaction receipt:

Error: Transaction ran out of gas. Please provide more gas

I have tried upping the gas, the gasPrice, the value. My account should have more than enough Eth to cover the transaction. I have tried estimating the cost of the transaction as well, which returns a slightly different error:

Error: Returned error: gas required exceeds allowance or always failing transaction

I've been struggling with this and cannot figure out how to get this contract working, as you can see from the history of failed transactions linked to that account. If someone could help me tweak the code above to get it working or can post an example of themselves calling the Etheroll contract, or another similar contract I could try to call, that'd be great.

  • 2
    It's not running out of gas. It's actually using very little gas (23814), which implies it's failing very quickly in the tx. I'd suspect it's failing in betIsValid. You can run a geth or parity trace to get more details on why it fails – Raghav Sood Jul 29 '18 at 23:44
  • Thanks for the insight. I will attempt to debug it and trace the transaction – rickjerrity Jul 30 '18 at 0:00

Your Answer

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

Browse other questions tagged or ask your own question.