0

Here is an example of constructing an ethereum transaction

var rawTx = {
  nonce: '0x00',
  gasPrice: '0x09184e72a000',
  gasLimit: '0x2710',
  to: '0x0000000000000000000000000000000000000000',
  value: '0x00',
  data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057'
}

var tx = new Tx(rawTx);
tx.sign(privateKey);

What is the unit of the 'value' field in rawTx? I can see that it is represented in hex in the transaction, but I've seen other examples that represent ludicrous amounts in decimal so I'm guessing the unit is not ether.

1

The title of your question asks about the "value" field, but the body of your question asks about the "to" field.

The "value" field is in wei. (10^18 wei == 1 ether) You can use hexadecimal or decimal to represent the number.

The "to" field is an address. It's 20 bytes long and probably always represented in hexadecimal.

  • I apologize! Typo – arshbot Mar 7 '18 at 0:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.