|
Step 7. GasPrice vs GasLimit vs GasUsedStep |
|
Subject: Step 7. GasPrice vs GasLimit vs GasUsedStep
Author: WebSpider
In response to: Step 6. Make sure the contract is deployed on the blockchain
Posted on: 06/07/2021 07:14:08 AM
gasPrice -- It varies around 30 Gwei depending on the demand and supply on the blockchain. It's irrelvent to your transaction's size and complexity. But if you want your transaction to be mined into chain faster, you better set a higher gas price for your transaction. gasLimit -- It is limit which varies from 20,000 to 1,000,000 depending on your transaction's size and complexity. You can estimate a gas and then set a limit to cap the gas to burn. Of course, your transaction could fail due to out of gas, if you under-estimated your gasLimit. gasUsed -- It is the gas actually used by miners to execute your transaction.
// estimate gas cost
let deploy_estimateGas = await web3_conn.eth.estimateGas( {
data: BYTECODE,
from: accounts[0]});
console.log('Deploy estimateGas: ', deploy_estimateGas);
Output:
Deploy estimateGas: 170065
It should be noted that the estimated value 170065 is the exact number actually used by the blockchain for this case.
>
> On 06/07/2021 07:10:59 AM WebSpider wrote:
After successful deployment of your contract, you should see something similar to the following:
Contract deployed at address: 0x01bf16cfCA22a5CeDa1291DD9512a1BF2A1A44A9
For further verification, you can look up your contract on https://ropsten.etherscan.io/
...
From: 0x7b6ee9541a2741a9f2631fbed9ffc532746be2de
To: Contract 0x01bf16cfca22a5ceda1291dd9512a1bf2a1a44a9Created
Value: 0 Ether ($0.00)
Transaction Fee: 0.00510195 Ether ($0.00)
Gas Price: 0.00000003 Ether (30 Gwei)
Gas Limit: 1,500,000
Gas Used by Transaction: 170,065 (11.34%)
Nonce Position: 0
Input Data: 0x608060405234801561001057600...
It should be noted: The miners sucked out all 30 Gwei for gasPrice set for this transaction, even though the average gasPrice for Ropsten is 2 Gwei at this point. The miners honored how much gas should be burned to execute the transaction, but they won't be mercy to take all of your gas and fail your transaction if your gasLimit is reached in the middle of execution.
References:
|
|
|
|