Solidity Out of Gas Error – How to Solve VM Exception While Processing Transaction

contract-developmentganacheout-of-gassolidityweb3js

i am trying to call this function with help of web3.js in ganache testrpc but it is giving me error of VM Exception while processing transaction: out of gas

i have tried to increas gas of ganache to 999999999999 still its not work…

function initialEscrowDetail(uint transactionId,address partyB,uint
amount,bool condition){

    escrowDetail[transactionId].originator=msg.sender;
    escrowDetail[transactionId].beneficiary=partyB;
    escrowDetail[transactionId].amount=amount;
    escrowDetail[transactionId].payoutCondition=condition;
    escrowDetail[transactionId].escrowCompleted=false;
}

enter image description here

Best Answer

The default gas in web3 if it is not specified is 90k. Since each new storage modifications cost 20k with 5 storage modifications you were using more than 100k of gas.

You can add an optional last parameter with the transaction gas

escrow.initialEscrowDetail(1,"0x0",200,true, { gas: 1000000 });
Related Topic