0

how to decide gas price while writing smart contract ? and how to know how much gas is going to be used while each token transaction ? and on

https://ethgasstation.info/

mentioned price is

SafeLow (<30m) 1 Standard (<5m) 4 Fast (<2m) 20

so is it based on per transaction ? big confusion can anyone help on this ?

0

2 Answers 2

1

how to decide gas price while writing smart contract ? and how to know how much gas is going to be used while each token transaction ? and on

Gas price is for miners value. Mostly miner will decide that is price for each step.

While writing you need to focus on Gas. Each step is chargeable in Eth.

Generating transaction, you need to specify gas price. You can get current using web3.eth.gasPrice in web3js.

For more details:

https://www.reddit.com/r/ethereum/comments/6gycvw/difference_between_increasing_gas_vs_gas_price/

1

how to decide gas price while writing smart contract ?

There are two things you need to think about:

  1. When writing your contract: The amount of gas your contract takes;
  2. When interacting with your contract on the blockchain: The gas price.

You don't decide the gas price when writing the contract, but you want to minimise the price you have to pay when you come to use your contract later on by minimising the gas your contract uses. To do this you need to make your contract as efficient as possible, to ensure it uses the smallest number of EVM instructions possible.

See: What is meant by the term "gas"?

and how to know how much gas is going to be used while each token transaction ?

That depends how on well you have written your contract. An efficient contract will minimise the gas used. (This isn't the same as gas price.)

See: How do I know how much gas to use when calling a contract?

See: How were gas costs chosen for the Ethereum Virtual Machine instructions?

and on https://ethgasstation.info/ mentioned price is SafeLow (<30m) 1 Standard (<5m) 4 Fast (<2m) 20

When you send a transaction, these values give you an estimate of how long that transaction will take for different gas prices. In your example, if you want your transaction to go through quickly, within 2 minutes, you would use the gas price under "Fast". If you're not in a rush, and don't mind waiting up to 30 minutes, you would use the gas price under "SafeLow".

See: Determine network congestion, min required gas/gas price based on current conditions

so is it based on per transaction?

Yes.

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.