0

I'm very confused on the concept of gas.

From what I understand, gas is a unit of ethereum, that measures the cost of a transaction. I'm not sure why we call it gas and separate it from ethereum. I read it measures the "technical cost" not "market cost" which makes no sense to me on how.

On average, it takes me $0.10 to send a transaction. So, does this mean when you run out of gas you have less than $0.10 cents of ethereum?

3 Answers 3

1

Ethereum has the concept of smart contracts. The gas measure the execution of smart contracts. The idea is that complex contracts will use more resources so they should pay more to be executed.

The gas measures the programing part of the transaction. As stated by @KaranKurbur each operation has a cost. Those costs were calculated so that simple operations are cheap and more complex operations are more expensive.

Each block has a gas limit (that is decided by miners), that allows to limit how many transaction are executen in a block. Also this can be seen as a security measure to limit malicious contracts from attacking the network.

0

Each opcode has a cost associated with it. Is there a table of EVM instructions and their gas costs?

You can aprox your gas costs due to what opcodes will be called and such.

0

Let me try to explain in my way:

Suppose you are going to some place in your new car. For that you need to fill the petrol tank to start your drive. Similarly to deploy the contract, we need to buy gas. We are calculating that these much gas will be required for the deployment, like you are estimating that these much petrol will be need. What will happen when you are estimated litre of petrol is not enough to cover you distance? Like that the contract said to be run out of gas.

But in this case, once you run out of the gas, you will loose the gas you spend and also you need to start from the beginning.

For technical details refer :

https://github.com/sruthi23/solidity/blob/master/gas.md

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.