2

I am using Truffle Framework and TestRPC. I have the following method on my contract:

function sendEmr(address receiver, string universalPatientId, string firstName, string lastName, string url) returns(bool val){

    emrRecords[receiver].universalPatientId = universalPatientId;
    emrRecords[receiver].firstName = firstName;
    emrRecords[receiver].lastName = lastName;
    emrRecords[receiver].url = url;

    EMRTransfer(msg.sender, receiver, universalPatientId, firstName, lastName, url);

    return true;
}

When I execute this method from my DAPP; I am receiving the following error in TESTRPC:

eth_accounts
eth_call
eth_call
eth_sendTransaction

  Transaction: 0xe212676e7b4b906d01932d7d2b7de9872d4e2a46e7730fee22e7488756f00d08
  Gas usage: 0x015f90
  Block Number: 0x07
  Block Time: Thu Jun 22 2017 11:36:03 GMT-0500 (Central Daylight Time)
  Runtime Error: out of gas

What should I do to handle this situation. Thank you very much!

  • 1
    are you passing very long strings in function arguments? if yes then try passing small strings to see if that works. – Sanchit Jun 22 '17 at 18:04
  • @Sanchit - I tried just sending in 'A', 'B', 'C' for the arguments, still same error. Since I am just using this as experimental; is there a way to turn off the gas limit or is this not a possibility? – Flea Jun 22 '17 at 19:00
  • yes, while starting testrpc, give argument --gasPrice and give your Gas value. For e.g. - "testrpc --gasPrice 20000" – Sanchit Jun 22 '17 at 19:07
  • Also, do you have a lot of functions in a single contract? if yes then I recommend breaking them into multiple contracts. – Sanchit Jun 22 '17 at 19:08
  • was that of any help? – Sanchit Jun 22 '17 at 21:37
4

I ended up resolving this by passing in more gas when calling the contract's method:

For example:

web3.eth.sendTransaction({gas: <some large number>}) or someContract.someMethod(arg1, arg2, {gas: <some large number>}).

So in my case I did this:

meta.sendEmr(receiver, universalPatientId, firstName, url, {from: account, gas: 1000000});

Your Answer

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

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