Solidity – VM Exception While Processing Transaction: Out of Gas Error

contract-developmentdappsout-of-gassolidity

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 }));
}


}

Best Answer

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})

Related Topic