How to use web3.eth.getTransactionReceipt
This article introduces the relevant knowledge of "how to use web3.eth.getTransactionReceipt". 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!
Specify a transaction hash and return a receipt for a transaction. It should be noted that receipts are not available for transactions in the pending state.
Call:
Web3.eth.getTransactionReceipt (hashString [, callback])
Parameters:
HashString: String-Hash of the transaction
Callback: Function-callback function to support asynchronous execution of 7.
Return value:
Object-the receipt object for the transaction, if not found, return null
BlockHash: String-32 bytes, the hash of this exchange in the block.
BlockNumber: Number-the block number of the block where the exchange is located.
TransactionHash: String-32 bytes, the hash value of the transaction.
TransactionIndex: Number-the serial number of the transaction in the block, integer.
From: String-20 bytes, the address of the transaction sender.
To: String-20 bytes, address of the recipient of the transaction. If it is a deal created by a contract, return null.
CumulativeGasUsed: Number-the total gas value of the cumulative cost after the execution of the current transaction.
GasUsed: Number-the gas spent separately to execute the current transaction.
ContractAddress: String-20 bytes, the address of the contract created. If it is a contract creation transaction, return the contract address, and otherwise return null.
Logs: Array-an array of log objects generated by this transaction.
Example:
Var receipt = web3.eth.getTransactionReceipt ('0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b'); console.log (receipt) {"transactionHash": "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b", "transactionIndex": 0, "blockHash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46", "blockNumber": 3, "contractAddress": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "cumulativeGasUsed": 314159, "gasUsed": 30234, "logs": [{/ / logs as returned by getFilterLogs, etc.},...]} "how to use web3.eth.getTransactionReceipt" is introduced 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!