[Ethereum] value, gas and gasprice format in web3

web3js

Based on web3js 1.0

value – Number|String|BN|BigNumber
gas – Number
gasPrice – Number|String|BN|BigNumber

Does gasPrice and value accept both number and hexadecimal value and will do the conversion automatically? And what is the correct unit for value, gas and gasPrice. All in wei?

Best Answer

As per Ethereum,

Gas is a unit or number of steps to be execute for your contract. Gas has fixed number of units for a specific operation/computation, this is fixed by Ethereum community. For example to add two numbers EVM consumes it may consumes 3 gas units.

VALUE field - The amount of wei to transfer from the sender to the recipient,

GASPRICE value, representing the fee the sender is willing to pay for gas. One unit of gas corresponds to the execution of one atomic instruction, Gasprice will in wei. Wei is a smallest unit.

Related Topic