I am running into out of gas exception while calling this function : contractInstance.createProposal("ADHD", "Foo", 2, {from: web3.eth.accounts[1]}) . I'm super new to ethereum and I would really appreciate some help!

Here's my super simple contract

pragma solidity ^0.4.2;

contract DataProvider {

struct Proposal {
    address owner;
    uint id;
    bytes16 name;
    bytes32 desc;
    uint pool_size;
    address[] consents;
    bool initialized;

address public admin;
Proposal[] public proposals;

function DataProvider() {
    admin = msg.sender;

function createProposal(bytes16 nm, bytes32 ds, uint n) {
    address[] memory cons;
    proposals.push(Proposal({ owner: msg.sender, id: proposals.length, name: nm, desc: ds, consents: cons, pool_size: n, initialized: true }));

  • 3
    with a gas limit of 3000000 your code works properly
    – Badr Bellaj
    Commented Sep 17, 2017 at 8:44
  • 1
    @itachi first welcome to the community, since you seem to be new to the community, FYI, It's better and would be useful when answering an question if you can mention what you tried to solve the problem and what were the outputs of those when asking a question. Good luck :) . Commented Sep 17, 2017 at 10:36
  • 1
    @AchalaDissanayake Gotcha, will do next time for sure :) Thanks for being so kind about it!
    – itachi
    Commented Sep 17, 2017 at 12:57

2 Answers 2


First check your account balance : balance = web3.eth.getBalance(someAddress); then try to specify the gaslimit contractInstance.createProposal("ADHD", "Foo", 2, {from: web3.eth.accounts[1], gas:3000000})

  • 3
    Awesome, thanks! :) Also, I had a couple other functions too which I haven't included for simplicity but then they all worked fine. Why does this function consume so much more gas than others?
    – itachi
    Commented Sep 17, 2017 at 9:20
  • 1
    it depends on the computation and the used storage
    – Badr Bellaj
    Commented Sep 17, 2017 at 9:23
  • 1
    @BadrBellaj I changed the gas limit to 3000000 using remix. But its still giving me out of gas error. Did i have to change gas price as well? My current gas price is 20000000000. Commented Sep 15, 2019 at 6:03

The solution from Badr Bellaj worked for me but I had to specify contractInstance.method.myMethod instead of just contractInstance.myMethod. This made me looking for a solution for days although I tried this immidiatly after the error occured.

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.