question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error (in browser):

VM Exception while processing transaction: out of gas

Contract:

pragma solidity ^0.4.6;

contract OpenCredentials {

    struct Certificate {
        address issuer;
        address candidate;
        string data;
    }

    struct Account {
        string public_key;
        Certificate[] certificates;
    }

    mapping (address => Account) public accounts;

    function register(string _pk) {
        accounts[msg.sender].public_key = _pk;
    }

    function assert(address _candidate, string _data) {
        accounts[_candidate].certificates.push(Certificate(msg.sender, _candidate, _data));
    }

    function isRegistered(address _address) public constant returns(bool) {
        return bytes(accounts[_address].public_key).length != 0;
    }

    function getCertificatesCount() public constant returns(uint) {
        if(!isRegistered(msg.sender)){
            return 0;
        }
        return accounts[msg.sender].certificates.length;
    }
}

contracts.json:

{
  "default": {
    "gas": "auto",
    "contracts": {
    }
  }
}

genesis.json:

{
  "nonce": "0x0000000000000042",
  "difficulty": "0x0",
  "alloc": {
    "0x7090981e522b810635e5147236f5eb20b6f3bfb2": {"balance": "15000000000000000000"}
  },
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x7090981e522b810635e5147236f5eb20b6f3bfb2",
  "timestamp": "0x00",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "extraData": "0x",
  "gasLimit": "0x4c4b40"
}

app.js:

$('#create').on('click', function(){
		OpenCredentials.assert(account.address, "Test message")
			.then(function(code){
				console.info("Successfully awarded certification!");
			})
			.catch(function(error){
				console.error(error.message);
			});
	});

Amount of ether in coinbase:

web3.fromWei(web3.eth.getBalance(web3.eth.coinbase), "ether").toNumber(); //99.9999999999994

Literally cannot understand why the hell i’m getting this error. I’ve searched the web for several hours but still no solution.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8

github_iconTop GitHub Comments

3reactions
iurimatiascommented, Jan 30, 2017

There seems to be an issue with the ‘auto’ feature as it seems to max at 700.000 gas, a fix should be coming soon. If this happens, it’s necessary to manually set the gas value to a higher value. note that you can change the gas for a specific contract with:

  {
  "default": {
    "gas": "auto",
    "contracts": {
       "OpenCredentials": {
          "gas": 900000
       }
    }
  }
}
1reaction
iurimatiascommented, Jan 30, 2017

@vincentracine the config on contracts.json only affects the contract creation, not calling individual methods. for the later it’s often needed to specify the gas value if the methods are too heavy (this is a very common issue when interacting with contracts). To specify it’s something like Contract.method(arg1, arg2, {gas: 500000})

Read more comments on GitHub >

github_iconTop Results From Across the Web

What to do if you run out of gas - Nationwide
What to do when your car runs out of gas · Turn on your hazard lights and pull over · Do you have...
Read more >
3 Things To Do If Your Car Runs Out Of Gas - Sullivan Tire
Here are 3 things to do if your vehicle runs out of gas and you're stuck on the road. Learn more at sullivantire.com....
Read more >
What To Do If You Run Out of Gas - Metromile
Warning signs that you've run out of gas · Get off the road and turn on emergency blinkers · Identify where you are...
Read more >
Run Out Of Gas Service - GetResqued
Run out of gas or gas gauge shows 'E' and your vehicle won't start? Use our free Roadside Assistance membership (mobile app) to...
Read more >
Out of Gas: The End of the Age of Oil (Norton Paperback)
With its easy-to-grasp explanations of the science behind every aspect of our most urgent environmental policy decisions, Out of Gas is "a handbook...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found