# what unit is used for the gas/gas limit in the ethereum/types lib?

I'm trying to create a raw transaction using NewTransaction send 1ETH to one transaction, set 21000 gasLimit(I understand this is fixed for any simple transaction) and set the gas price to 51 Gwei.

The issue I have is that there is no documentation about the unit used for Amount, gasLimit and gasPrice. Is it safe to use `big.NewInt(1)` (for 1ETH), `uint64(21000)` for gasLimit and `big.NewInt(51)` for gasPrice ?

``````NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit
uint64, gasPrice *big.Int, data []byte) *Transaction
``````

Everything is represented in Wei. Wei is the smallest unit of ethereum. Gas limit (in your case 21000) is just 21000. Gas price is represented in Gwei

``````1 Gwei = 10^9 Wei = 1,000,000,000 Wei
``````

The amount to send in represented in Wei

``````1 Ether = 10^18 Wei = 1,000,000,000,000,000,000 Wei
``````

So for representing `5 ether` you can use `5*(10^18)` and for representing `50 Gwei` you can use `50*(10^9)` .

There are web3 methods to directly convert these units in web3 docs.

• So after all not everything is represented is Wei. The gas price is i n Gwei and the amount is in Wei. Commented Jan 18, 2018 at 8:11
• The gas too is represented in Wei. But the gas price 51 is in Gwei. So if gas price is 50 then 50*(10^9) and if the amount is 5 ether then 5*(10^12). Hope this helps. If you need more detail I can edit the post and post a more detailed answer. Commented Jan 18, 2018 at 9:09
• Is there any method function to do the conversion in Go ? web3 is a javascript sdk as far as I can see. Commented Jan 18, 2018 at 10:52
• There is a 3rd party support code for accessing web3 using go lang. github.com/regcostajr/go-web3 Though I would recommend using the web3js which is officially supported. You might also wanna check this godoc.org/github.com/jaynagpaul/go-web3 Commented Jan 19, 2018 at 1:27
• Just to be clear: gas itself is an abstract unit of work that exists inside the EVM - it doesn't have a unit of wei or ether. The gas price has a unit of wei (or Gwei/ether). Commented May 20, 2018 at 20:59