 Leave your answers to the questions below in this thread. If you have any questions or you want to discuss something connected to the assignment feel free to do it in this thread as well, but please everything to the topic.

1. How do we calculate the total gas cost for a transaction?
2. What is gas limit?
3. What happens if we specify a gas limit that is too low?
4. What happens if we specify a gas limit that is too high and therefore not consumed fully?
5. What is a gwei?
2 Likes
1. You add up all the gas costs for executing each part of a transaction and use of a smart contract.
2. It is the maximum cost of gas a user is willing to pay for a transaction or deployment of a smart contract.
3. The transaction will not execute fully and be rejected. The Ether transaction fee will be lost, but the main funds, if the transaction was sending funds, will not leave the wallet.
4. Unspent gas will be refunded automatically.
5. 1 gwei is 1 billion wei. A wei is one unit or Ether.
1 Like
1. How do we calculate the total gas cost for a transaction?
We calculate the total gas cost for a transaction by summing the cost of each operation. The cumulative sum of all the operations is the total gas cost for the transaction. There are calculators.

2. What is gas limit?
The gas limit is the maximum amount of gas you are willing to spend on the transaction.

3. What happens if we specify a gas limit that is too low?
Your transaction will start to be executed, but will eventually run out of gas and be stopped. When this happens, you will not get back ether spend on the gas used, but since the transaction did not complete, the blockchain does not reflect a transfer, so the main funds essentially never left the wallet.

4. What happens if we specify a gas limit that is too high and therefore not consumed fully?
You will not get back ether spend on the gas used, but since the transaction did not complete, the blockchain does not reflect a transfer, so the main funds essentially never left the wallet.

5. What is a gwei?
The gas price is usually some amount of gwei. Wei is the smallest unit of ether, and gwei is simply 1000000000 wei.

1 Like
1. How do we calculate the total gas cost for a transaction?
The total Gas cost is calculated by adding up all the pre-determined costs per operation but the transaction cost is subject to a minimum of 21000 Gas plus the cost of any fall back functions if its sent to a contract.

2. What is gas limit?
Gas Limit is the maximum amount of gas that you are willing to pay for a transaction.

3. What happens if we specify a gas limit that is too low?
The transaction will start but then fail and any Ether spent on used gas will not be returned although no transfer of Ether will take place because the transaction failed and was not added to a block.

4. What happens if we specify a gas limit that is too high and therefore not consumed fully?
Because Ethereum blocks have a gas limit size, it is likely that the transaction will stay in the Mempool as Miners will not want to deal with the transaction because it is not computationally dense enough. This is because the miners only get paid for the actual gas consumed to perform a transaction.

5. What is a gwei?
A Gwei is a fractional part of Ether in that is represents 1000000000 wei. Wei is the smallest unit of Ether.

3 Likes

How do we calculate the total gas cost for a transaction?
The total Gas cost is calculated by adding up all the predetermined costs per operation, but the transaction cost is subject to a minimum of 21000 Gas plus the cost of any fall back functions.
What is gas limit?
Gas Limit is the maximum amount of gas that you are willing to pay.
What happens if we specify a gas limit that is too low?
The transaction will start but then fail and any Ether spent on used gas will not be returned, although no transfer of Ether will take place because the transaction failed and was not added to the block.
What happens if we specify a gas limit that is too high and therefore not consumed fully?
Because Ethereum blocks have a gas limit size, it is probable that the transaction will stay in the Mempool as Miners will not want to deal with the transaction because it is not computationally dense enough. This is because the miners only get paid for the actual gas consumed to perform a transaction.
What is a Gwei?
A Gwei is a fractional part of Ether in that is represents 1000000000 wei. Wei is the smallest unit of Ether.

1 Like

How do we calculate the total gas cost for a transaction?
You calculate each function that are processed. Minimum 21000 as a base. Then you also add gas for interacting with a contract like storing or processing integers in add or subtract functions. Gas is dynamic depending of market. Its good to make well written smart contracts with computational complexity off-chain and only update states on chains.

What is gas limit?
The minimum are 21000 gas for simple transfers and the maximum 4700000 gas .

What happens if we specify a gas limit that is too low?
The TX will not be confirmed if the TX runs out of gas. You will not get back the gas spend.

What happens if we specify a gas limit that is too high and therefore not consumed fully?
Miners are only payed for consumed gas. You set a maximum you are willing to pay n total and the gas that not are consumed will be refunded back to you.

What is a gwei?
Gwei are a sub-currency of Ether. There are several calculators you can use.

1 Like
1. Well, key point is I think, unless you are doing crazy large amount of transactions, you don’t need to calculate the cost so long as you are within the upper and lower limits for your transaction to be accepted. Otherwise, you would need to add up the cost of each computation and find a matching price, find the current gas price, and start calculating.
2. Gas Limit is the upper boundary of how much you are willing to spend on the execution.
3. Your gas will be lost and the execution will stop once it runs out of gas. You will loose your gas, but since the execution did not complete, everything else will be as it was.
4. If it is below the upper bounds of the block limits, you will be refunded the difference, if it is too crazy high, the contract may not execute as there is a gas limit in the blocks as well, and there may not be room.
5. It is a measurement with 9 zero’s I believe. So it would be 1 billion wei.
1 Like
1. How do we calculate the total gas cost for a transaction?
It’s caclulated based on the types of operations. Some things are free. Some things are very expensive.

2. What is gas limit?
It’s the max amount of gas the programmer defines when submitting a transaction.

3. What happens if we specify a gas limit that is too low?
The transaction will process until the lmiit is met. If it’s too low, the transaction will stop (get rolled back / not committed) and the user will not get their spent gas back.

4. What happens if we specify a gas limit that is too high and therefore not consumed fully?
It doesn’t have any impact on the programming execution, but if the gas limit is too high, it may get kicked out because of the overall limit for the entire block. I spent a solid 3 days fighting this problem when I wrote my contract.

5. What is a gwei?
It’s a smaller unit of the price of ethereum. Gas is the equivalent of micro pennies. So, by using a smaller unit, it’s easier to digest than writing the gas price as .0000210000 Eth

1 Like
1. How do we calculate the total gas cost for a transaction?
https://ethgasstation.info/ or manual using the cost per item chart and then factoring in the current transaction on the network using ether scan.

2. What is gas limit?
The max fee to pay for a transaction to go through

3. What happens if we specify a gas limit that is too low?
The miner gets the fee but the transaction does not go through.

4. What happens if we specify a gas limit that is too high and therefore not consumed fully?
The unused gas is refunded but the transaction might not be processed as each block has a gas limit.

5. What is a gwei?
The measurement for Gas used on Ethereum network.

1 Like

1. How do we calculate the total gas cost for a transaction?
By adding up costs of all functions based on each line of code and it’s computational requirements. Simple operation costs less, more complicated operation like smart contract costs more.

2. What is gas limit?
The maximum amount of gas you’re wiling to spend on a transaction.

3. What happens if we specify a gas limit that is too low?
Failed transaction. The contract will execute but eventually run out of gas and stop, the miner will keep the ether you pay for gas (means you loss it), and your main fund stays in original wallet as the blockchain doesn’t reflect a transfer .

4. What happens if we specify a gas limit that is too high and therefore not consumed fully?
It will be returned to you as ether.

5. What is a gwei?
Measurement unit for gas in relation to ether - 1,000,000,000 wei.

1 Like
1. How do we calculate the total gas cost for a transaction?
• the sum of all operations (with pre-determined costs) used in the transaction
2. What is gas limit?
• the maximum amount of gas that you are willing to pay for a transaction
3. What happens if we specify a gas limit that is too low?
• the transaction will fail and gas spent lost
4. What happens if we specify a gas limit that is too high and therefore not consumed fully?
• only the consumed gas of the transaction is spent, unused is refunded
5. What is a gwei?
• a fractional measurement unit for Ether that represents 1000000000 wei
2 Likes
1. How do we calculate the total gas cost for a transaction?
It’s depend on the complexity of each operation. The more it is complex the more it cost. The cumulative sum of all the operations is the total gas cost for the transaction
2. What is gas limit?
It corresponds to the maximum amount of gas you are willing to spend on the transaction, the minimum is 21000
3. What happens if we specify a gas limit that is too low?
Insufficient gas in the Gas Limit will result in a failed transaction, the fee paid will be lost, but the ether transferred never leaves the wallet since the blockchain was never updated.
4. What happens if we specify a gas limit that is too high and therefore not consumed fully?
Extra, unspent gas is refunded automatically.You cannot exceed the gas limit of the blocks if you wish for your transaction to be processed.
5. What is a gwei?
It’s 1000000000 wei and Wei is the smallest unit of ether
1 Like
1. How do we calculate the total gas cost for a transaction?
The total gas cost can be calculated in many ways. One way is to look at the contract code to determine what the exact cost for each unit is.
2. What is gas limit?
Gas limit is the maximum amount of gas allotted to a transaction.
3. What happens if we specify a gas limit that is too low?
We will run out of gas and the transaction will not be completed.
4. What happens if we specify a gas limit that is too high and therefore not consumed fully?
Unspent gas is automatically refunded.
5. What is a gwei?
Wei is the smallest amount of Ether and gwei is 1000000000 wei
1 Like

1. How do we calculate the total gas cost for a transaction?
It is the cumulative sum of all the operations involved.
2. What is gas limit?
It corresponds to the maximum amount of gas possible to expend on the transaction.
3. What happens if we specify a gas limit that is too low?
The operation fails and the fees are kept by the miner. The application starts but will stop and the gas used will not get back, if the transaction is not complete , main founds will never leave the wallet.
4. What happens if we specify a gas limit that is too high and therefore not consumed fully?
The extra will be refunded automatically.
5. What is a gwei?
It is 1E9 wei where 1 wei is the smallest ether unit. Gas price is usually measured in gwei.

How do we calculate the total gas cost for a transaction?

The cumulative sum of all the operations is the total gas cost for the transaction.

What is gas limit?

The MAXIMUM amount of gas you are willing to spend on the transaction.

What happens if we specify a gas limit that is too low?

Your transaction will start to be executed, but will eventually run out of gas and be stopped. When this happens, you will not get back ether spend on the gas used, but since the transaction did not complete, the blockchain does not reflect a transfer, so the main funds essentially never left the wallet.

What happens if we specify a gas limit that is too high and therefore not consumed fully?

The blocks have a gas limit that specifies the maximum amount of gas all transactions in the block can consume. You cannot exceed this amount if you wish for your transaction to be processed. Miners only get paid for the actual gas consumed by a transaction, you are returned the remainder.

What is a gwei?

• gwei is a fractional part of Ether
• It represents 1000000000 wei. Wei represents 1 and is the smallest unit of Ether
2 Likes

1. How do we calculate the total gas cost for a transaction?
Transactions on the Ethereum network require fees in the form of gas. The amount of gas depends on the amount of computation required to complete the transaction.
2. What is gas limit?
MAXIMUM amount of gas you are willing to spend on the transaction, 21000 being sufficient for simple transfers and much higher amounts for transfers to smart contracts like those in ICOs.
3. What happens if we specify a gas limit that is too low?
Providing too little gas will result in a failed transaction, the fees are kept by the miner. So insufficient gas in the Gas Limit will result in a failed transaction, the fee paid will be lost, but the ether transferred never leaves the wallet since the blockchain was never updated.
4. What happens if we specify a gas limit that is too high and therefore not consumed fully?
Extra, unspent gas is refunded automatically.
5. What is a gwei?
It is a unit of gas price measured in a fraction of ether. It can be furher divided into wei. So 1 gwei = 1000000000 wei (smallest unit of ether).

1 Like

How do we calculate the total gas cost for a transaction?

Total gas is the cumulative sum of all the operations for the transaction plus 21000 Gwei for the transation.

What is gas limit?

It’s the maximum amount of units of gas you are willing to spend on a transaction.

What happens if we specify a gas limit that is too low?

You will get an “out of gas” failure and the gas will be kept by the miners and your ETH that was to be sent will remain in your wallet.

What happens if we specify a gas limit that is too high and therefore not consumed fully?

You’ll get the refund of unused gas limits.

What is a gwei?

Gwei is a denomination of gas that is equal to 0.000000001 ether .

1 Like
• How do we calculate the total gas cost for a transaction?
There are table where you can see how much gas costs for an action

• What is gas limit?
it is the maximum amount of gas that is used for a transaction.

• What happens if we specify a gas limit that is too low?
If its to low the contract wont execute

• What happens if we specify a gas limit that is too high and therefore not consumed fully?
Etherum Blocks have a gas limit size. If its still to high the gas will be refunded to you since the miners only get the gas if they use it.

• What is a gwei?
Wei is the smallest unit of ether and a gwei is 1000000000 wei.

1 Like
• How do we calculate the total gas cost for a transaction?
``````TotalGasCost = GasPrice * GasConsumedAmount;
``````
• What is gas limit?

A limit of computational power “fuel” to prevent smart contracts from being exploited.

• What happens if we specify a gas limit that is too low?

The code of a smart contract would not be fully executed and the sender would loose all the ether for the consumed gas (which goes to the miners).

• What happens if we specify a gas limit that is too high and therefore not consumed fully?

The transaction might not get accepted by the miners as it is not enough economically attractive.
I understand it as

``````The block would incorporate less transactions if some of them have large gas limit.
``````

I have not fully understood the explanations of subj provided in the article, so it would be nice to have a comment by @filip

• What is a gwei?

10^9 wei

How do we calculate the total gas cost for a transaction?

This is calculated based on the code. Each line of code has a specific gas price associated with it so the cost is aggregated when the transaction is read by the EVM.

What is gas limit?

The gas limit is set by the sender of the transaction. It is the maximum amount the sender is willing to pay for the transaction.

What happens if we specify a gas limit that is too low?

Your transaction will run out of gas and land back in your wallet, BUT your transaction fee will go to the miner. Any ‘excess’ transation fees beyond the gas used will also be refunded back to your wallet.

What happens if we specify a gas limit that is too high and therefore not consumed fully?

you risk having your transaction rejected because each block has a gas limit so the miners may not transaction because it would push the blocks gas limit over.

What is a gwei?

The gas price for a transaction on the ethereum blockchain is the amount of Ether you are willing to spend on every unit of gas. This ‘gas price’ is typically measured in Gwei which is 1000000000 wei (the smallest unit of Eth).