How to use web3.eth.getTransaction
This article introduces the relevant knowledge of "how to use web3.eth.getTransaction". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Returns a transaction that matches the specified transaction hash value.
Call:
Web3.eth.getTransaction (transactionHash [, callback])
Parameters:
TransactionHash: String-the hash value of the transaction.
Callback: Function-callback function to support asynchronous execution of 7.
Return value:
Object-A trading partner
Hash: String-32 bytes, the hash value of the transaction.
Nonce: Number-the number of transactions previously made by the initiator of the transaction.
BlockHash: String-32 bytes. The hash value of the exchange in the block. Null will be returned when the block is in pending.
BlockNumber: Number-the block number of the block where the exchange is located. Null will be returned when the block is in pending.
TransactionIndex: Number-an integer. The serial number of the transaction in the block. Null will be returned when the block is in pending.
From: String-20 bytes, address of the initiator of the transaction.
To: String-20 bytes, address of the recipient of the transaction. Null will be returned when the block is in pending.
Value: BigNumber-the amount of currency that comes with the transaction, in Wei.
GasPrice: BigNumber-the gas price configured by the initiator of the deal in wei.
Gas: Number-gas provided by the initiator of the deal. .
Input: String-data that comes with the transaction.
Example:
Var blockNumber = 668 per indexOfTransaction = 0var transaction = web3.eth.getTransaction (blockNumber, indexOfTransaction); console.log (transaction) / * {"hash": "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b", "nonce": 2, "blockHash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46", "blockNumber": 3, "transactionIndex": 0, "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f", "value": BigNumber, "gas": 314159, "gasPrice": BigNumber, "input": "0x57cb2fc4"} * / "how to use web3.eth.getTransaction" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!