4

Noob question about the Web3 Javascript API.

When I use web3.eth.getTransaction(), the object that comes back has some properties that I cannot seem to find in the documentation. For example, here is what I'm seeing when I run web3.eth.getTransaction().

{ blockHash: '0xf2a40da650009deb5b064660c2b3fd8030a1bb0e9e92ed38ab66813cc366c7e0',
  blockNumber: 3593309,
  from: '0x485fbe8fce05a862832ddc9464e96be131544c45',
  gas: 147622,
  gasPrice: { [String: '211000000000'] s: 1, e: 11, c: [ 211000000000 ] },
  hash: '0xdbbcb4d5be94f56ee23bcf7b9f42fa72294d6f5b735f994a05e122e2a2687f51',
  input: '0x9cf5453d000000000000000000000000485fbe8fce05a862832ddc9464e96be131544c45',
  nonce: 34,
  to: '0x1d0dcc8d8bcafa8e8502beaeef6cbd49d3affcdc',
  transactionIndex: 0,
  value: { [String: '500000000000000000'] s: 1, e: 17, c: [ 5000 ] },
  v: '0x26',
  r: '0x48a7fbc581ec4a7509cabbb0d603eceeaf5d43901128fa79b33f0bc73d41ad13',
  s: '0x4c006097a7fe312e9373a3c6488a16ba80d170c77a6b7a124437ac0796005ba2' }

For comparison, here is what the Web3 JavaScript documentation shows:

{ "hash": "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b",
  "nonce": 2,
  "blockHash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46",
  "blockNumber": 3,
  "transactionIndex": 0,
  "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
  "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
  "value": BigNumber,
  "gas": 314159,
  "gasPrice": BigNumber,
  "input": "0x57cb2fc4"}

What are the "v", "r", and "s" properties? And what are "s", "e", and "c" within the "value" object?

Is there an updated documentation I should be looking at? If it matters, I'm using web3 v 0.20.1 with a local instance of Geth.

Badr Bellaj
  • 18,780
  • 4
  • 58
  • 75
mgalka
  • 253
  • 2
  • 7

2 Answers2

3

For more details, as mentioned before these letters are bignumber Properties:

c: coefficient
e: exponent
s: sign

The value of a BigNumber is stored in a decimal floating point format represented by a coefficient, exponent and sign, e.g :

x = new BigNumber(-123.456);
x.c    coefficient (i.e. significand) == [ 123, 45600000000000 ]  
x.e     exponent == 2                      
x.s    sign == -1                       

Coefficient -from the bignumber doc :

From v2.0.0 of this library, the value of the coefficient of a BigNumber is stored in a normalised base 100000000000000 floating point format, as opposed to the base 10 format used in v1.x.x

sign is clear 1 or -1.

exponent e is the exponent of the exponential notation form (toExponential() ) e.g :

y.toExponential()  // '-1.234567e+4' => y=4

Concerning v, r, s they are described in the yellow paper as Values corresponding to the signature of the transaction and used to determine the sender of the transaction

ECDSASIGN(e ∈ B32, pr ∈ B32) ≡ (v ∈ B1, r ∈ B32, s ∈ B32)
Badr Bellaj
  • 18,780
  • 4
  • 58
  • 75
2

The values s, e, and c are found in the value and gasPrice attributes because they are instances of BigNumber. BigNumber maintains an internal representation of a number, so that it can handle larger numbers than javascript primitive numbers. (values in wei easily exceed this limit)

When using a BigNumber, you should just use its public API, no need to worry about the internal variables.


v, r, and s are values used to verify the signature on the transaction. Unless you are looking to re-verify the signature, you can safely ignore these.

carver
  • 6,381
  • 21
  • 51