In truffle saving 1 struct exceeds the default gas of testrpc. Is this function poorly written, or is this common in truffle.

VM Exception while processing transaction: out of gas


pragma solidity ^0.4.2;

contract SimpleStorage {
  mapping(address => Pass[]) passes; 

  struct Pass{
      string class_name;
      string first_name;
      string last_name;

  function submitPass(string classname, string firstname, string lastname){
          class_name: classname,
          first_name: firstname,
          last_name:  lastname



  this.state.web3.eth.getAccounts((error, accounts) => {
    simpleStorage.deployed().then((instance) => {
      simpleStorageInstance = instance;
      return simpleStorageInstance.submitPass("Intro 2 Truffle", "Alain", "Gold", {from: accounts[0]})

1 Answer 1


You can pass the gas value in contract method invocation like below:

return simpleStorageInstance.submitPass("Intro 2 Truffle", "Alain", "Gold", {from: accounts[0], gas: 200000})

You can check the actual required gas value in testrpc console. convert that from hex to decimal and that will be your required gas value.

You can put that gas amount in the contract method invocation or gas: 200000 would be sufficient and program should execute.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.