2

I use web3 to get a transaction (Ropsten testnet):

web3.eth.getTransaction("0xea73781d8cb2dcd73ab5c7e863a2c3e2e94f99b92e4e2b9f9316be38f151ef3b")

I get the following fields: blockHash, blockNumber, from, gas, gasPrice, hash, input

There are missing fields if I compare to etherscan: https://ropsten.etherscan.io/tx/0xea73781d8cb2dcd73ab5c7e863a2c3e2e94f99b92e4e2b9f9316be38f151ef3b

How do I access to the other fields: "Gas Used By Txn", "Gas Price" (at the tx time), "Nonce" and, more specifically, the field "To" ?

  • Can you print the full output you're seeing? I'm not sure why you would be missing nonce, but you should also see fields like r, s, and v. – carver Aug 25 '17 at 18:42
2

Nonce is inside the TX, so you can retrieve it with:

web3.eth.getTransaction("0xea73781d8cb2dcd73ab5c7e863a2c3e2e94f99b92e4e2b9f9316be38f151ef3b")

0xea73781d8cb2dcd73ab5c7e863a2c3e2e94f99b92e4e2b9f9316be38f151ef3b is a contract creation TX, so it contains a void to field. Etherescan shows insert in the To field of the web page the contract address created by the TX. That address, as all others post mining TX attributes, can be retrieved from the TX receipt:

web3.eth.getTransactionReceipt("0xea73781d8cb2dcd73ab5c7e863a2c3e2e94f99b92e4e2b9f9316be38f151ef3b");

The actual cost of the TX is the gas price (found in the TX) multiplied for gas used (found in the receipt).

2

When you send a transaction that creates a contract, the "to" field is empty. A contract is created at an address based on the sending address and the nonce.

For the rest, the fields are included. See this production example:

> eth.getTransaction("0x47d11e7b517a958974e1ff3e0b61598d702b710ac46a2075539b4477e41b4c63")
{
  blockHash: "0x1dd217b445ad9c4ca4627d30922dd7f672259a5b6c3416ebf92279b1ac6b6b85",
  blockNumber: 4203219,
  from: "0xafb92fd4a283ec760121e0947adb96ed7d2bf4b1",
  gas: 52385,
  gasPrice: 60000000000,
  hash: "0x47d11e7b517a958974e1ff3e0b61598d702b710ac46a2075539b4477e41b4c63",
  input: "0xa9059cbb0000000000000000000000008809f960bb6dada4ac6a853d7bb47c63aae1c05200000000000000000000000000000000000000000000000000000002fa7360c0",
  nonce: 14,
  r: "0xd3fc2856cbf9a5b8469ec1216a57c8fbb0db15a08ba45c0c005c171cd5addef7",
  s: "0x69b715b3e668aa6b5c019b6191f16506692ee79c47cef713a4f4633f718bd0eb",
  to: "0xd4fa1460f537bb9085d22c7bccb5dd450ef28e3a",
  transactionIndex: 0,
  v: "0x25",
  value: 0
}
> eth.getTransactionReceipt("0x47d11e7b517a958974e1ff3e0b61598d702b710ac46a2075539b4477e41b4c63")
{
  blockHash: "0x1dd217b445ad9c4ca4627d30922dd7f672259a5b6c3416ebf92279b1ac6b6b85",
  blockNumber: 4203219,
  contractAddress: null,
  cumulativeGasUsed: 37385,
  from: "0xafb92fd4a283ec760121e0947adb96ed7d2bf4b1",
  gasUsed: 37385,
  logs: [{
      address: "0xd4fa1460f537bb9085d22c7bccb5dd450ef28e3a",
      blockHash: "0x1dd217b445ad9c4ca4627d30922dd7f672259a5b6c3416ebf92279b1ac6b6b85",
      blockNumber: 4203219,
      data: "0x00000000000000000000000000000000000000000000000000000002fa7360c0",
      logIndex: 0,
      removed: false,
      topics: ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", "0x000000000000000000000000afb92fd4a283ec760121e0947adb96ed7d2bf4b1", "0x0000000000000000000000008809f960bb6dada4ac6a853d7bb47c63aae1c052"],
      transactionHash: "0x47d11e7b517a958974e1ff3e0b61598d702b710ac46a2075539b4477e41b4c63",
      transactionIndex: 0
  }],
  logsBloom: "0x00000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000008000000000000000000000000000000000000040001000000000000000800000000000080000000000000000000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000",
  root: "0xef7399bf8b2a9a1bddec13ad990afc3975a45209cf96663f3d98cb1d87957637",
  to: "0xd4fa1460f537bb9085d22c7bccb5dd450ef28e3a",
  transactionHash: "0x47d11e7b517a958974e1ff3e0b61598d702b710ac46a2075539b4477e41b4c63",
  transactionIndex: 0
}

Fields:

  • "Gas Price": see gasPrice
  • "Nonce": see nonce
  • "Gas Used By Txn": see gasUsed in the receipt

There is no way to see the dollar price of ether (now or in the past) by inspecting the transaction.

  • Please note that "gas" attribute is the gas attached by the sender during the TX creation, it's not the gas actually consumed by the TX. – Giuseppe Bertone Aug 25 '17 at 18:53

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.