3

Can you please explain the concept GAS in smart contract properly if possible with example. And what is the max limit of GAS in a contract?

It is clear if i use more gas i have to pay more...so where i can get that actual calculations.

2 Answers 2

3

There are many good YouTube presentations on this topic. I recommend one by Joseph Chow from ConsenSys. Watch it here: "Ethereum, gas, fuel, and fee" https://youtu.be/dd-ajiMl4HY

A contract call can take all gas per block if the contract tx is lucky enough to be the only one tx in a block or you mine a block yourself . The current gas limit can be checked on the network stats page. https://ethstats.net/

3

You can use the following Web3 JS function to estimate Gas before making any smart contract function call -

https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethestimategas

Also, the Gas Limit is defined in the genesis.json file, before initializing the genesis block.

You can take a look at this link to understand these concepts better -

https://souptacular.gitbooks.io/ethereum-tutorials-and-tips-by-hudson/content/private-chain.html

Your Answer

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

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