Comment
Author: Admin | 2025-04-28
HexBytes('0x45e0aff800961cfce805daef7016b9b675c137a6a41a548f7b60a3484c06a33a'), 'to': '0x5DF9B87991262F6BA471F09758CDE1c0FC1De734', 'transactionIndex': 0, 'type': 0, 'v': 28, 'value': 31337})Eth.get_raw_transaction(transaction_hash)Delegates to eth_getRawTransactionByHash RPC MethodReturns the raw form of transaction specified by transaction_hash.If no transaction is found, TransactionNotFound is raised.>>> web3.eth.get_raw_transaction('0x86fbfe56cce542ff0a2a2716c31675a0c9c43701725c4a751d20ee2ddf8a733d')HexBytes('0xf86907843b9aca0082520894dc544d1aa88ff8bbd2f2aec754b1f1e99e1812fd018086eecac466e115a0f9db4e25484b28f486b247a372708d4cd0643fc63e604133afac577f4cc1eab8a044841d84e799d4dc18ba146816a937e8a0be8bc296bd8bb8aea126de5e627e06')Eth.get_transaction_by_block(block_identifier, transaction_index)Delegates to eth_getTransactionByBlockNumberAndIndex oreth_getTransactionByBlockHashAndIndex RPC MethodsReturns the transaction at the index specified by transaction_indexfrom the block specified by block_identifier. Delegates toeth_getTransactionByBlockNumberAndIndex if block_identifier is aninteger or one of the predefined block parameters 'latest', 'earliest','pending', 'safe', 'finalized', otherwise delegates toeth_getTransactionByBlockHashAndIndex.If a transaction is not found at specified arguments, throws web3.exceptions.TransactionNotFound.>>> web3.eth.get_transaction_by_block(46147, 0)AttributeDict({ 'blockHash': '0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd', 'blockNumber': 46147, 'from': '0xA1E4380A3B1f749673E270229993eE55F35663b4', 'gas': 21000, 'gasPrice': None, 'hash': '0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060', 'input': '0x', 'maxFeePerGas': 2000000000, 'maxPriorityFeePerGas': 1000000000, 'nonce': 0, 'to': '0x5DF9B87991262F6BA471F09758CDE1c0FC1De734', 'transactionIndex': 0, 'value': 31337,})>>> web3.eth.get_transaction_by_block('0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd', 0)AttributeDict({ 'blockHash': '0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd', 'blockNumber': 46147, 'from': '0xA1E4380A3B1f749673E270229993eE55F35663b4', 'gas': 21000, 'gasPrice': None, 'hash': '0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060', 'input': '0x', 'maxFeePerGas': 2000000000, 'maxPriorityFeePerGas': 1000000000, 'nonce': 0, 'to': '0x5DF9B87991262F6BA471F09758CDE1c0FC1De734', 'transactionIndex': 0, 'value': 31337,})Eth.get_raw_transaction_by_block(block_identifier, transaction_index)Delegates to eth_getRawTransactionByBlockNumberAndIndex oreth_getRawTransactionByBlockHashAndIndex RPC MethodsReturns the raw transaction at the index specified by transaction_indexfrom the block specified by block_identifier. Delegates toeth_getRawTransactionByBlockNumberAndIndex if block_identifier is aninteger or one of the predefined block parameters 'latest', 'earliest','pending', 'safe', 'finalized', otherwise delegates toeth_getRawTransactionByBlockHashAndIndex.If a transaction is not found at specified arguments, throws web3.exceptions.TransactionNotFound.>>> web3.eth.get_raw_transaction_by_block('latest', 0)HexBytes('0x02f87582053901843b9aca00843b9aca008301d8a894e2dfcfa89a45abdc3de91f7a2844b276b8451d2e888ac7230489e8000080c001a028dcd2e11682288c00237f377280bc6a478a6b27e9c2d745262152add1b1dfcba04e7a33b7ce2a37fc3cd3af7bdc7d7beff721664d56508defa188df35afd77c2c')>>> web3.eth.get_raw_transaction_by_block(2, 0)HexBytes('0x02f87582053901843b9aca00843b9aca008301d8a894e2dfcfa89a45abdc3de91f7a2844b276b8451d2e888ac7230489e8000080c001a028dcd2e11682288c00237f377280bc6a478a6b27e9c2d745262152add1b1dfcba04e7a33b7ce2a37fc3cd3af7bdc7d7beff721664d56508defa188df35afd77c2c')>>> web3.eth.get_raw_transaction_by_block('0xca609fb606a04ce6aaec76415cd0b9d8c2bc83ad2a4d17db7fd403ee7d97bf40', 0)HexBytes('0x02f87582053901843b9aca00843b9aca008301d8a894e2dfcfa89a45abdc3de91f7a2844b276b8451d2e888ac7230489e8000080c001a028dcd2e11682288c00237f377280bc6a478a6b27e9c2d745262152add1b1dfcba04e7a33b7ce2a37fc3cd3af7bdc7d7beff721664d56508defa188df35afd77c2c')Eth.wait_for_transaction_receipt(transaction_hash, timeout=120, poll_latency=0.1)Waits for the transaction specified by transaction_hash to be included in a block, thenreturns its transaction receipt.Optionally, specify a timeout in seconds. If timeout elapses before the transactionis added to a block, then wait_for_transaction_receipt() raises aweb3.exceptions.TimeExhausted exception.>>> web3.eth.wait_for_transaction_receipt('0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060')# If transaction is not yet in a block, time passes, while the thread sleeps...# ...# Then when the transaction is added to a block, its receipt is returned:AttributeDict({ 'blockHash': HexBytes('0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd'), 'blockNumber': 46147, 'contractAddress': None, 'cumulativeGasUsed': 21000, 'from': '0xA1E4380A3B1f749673E270229993eE55F35663b4', 'gasUsed': 21000, 'logs': [], 'logsBloom': HexBytes('0x000000000000000000000000000000000000000000000000...0000'), 'status': 1, 'to': '0x5DF9B87991262F6BA471F09758CDE1c0FC1De734', 'transactionHash': HexBytes('0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060'), 'transactionIndex': 0,})Eth.get_transaction_receipt(transaction_hash)Delegates to eth_getTransactionReceipt RPC MethodReturns the transaction receipt specified by transaction_hash. If the transaction cannot be found throws web3.exceptions.TransactionNotFound.If status in response equals 1 the transaction was successful. If it is equals 0 the transaction was reverted by EVM.>>> web3.eth.get_transaction_receipt('0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060') # not yet minedTraceback # ... etc ...TransactionNotFound: Transaction with hash: 0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060 not found.# wait for it to be mined....>>> web3.eth.get_transaction_receipt('0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060')AttributeDict({ 'blockHash': '0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd', 'blockNumber': 46147, 'contractAddress': None, 'cumulativeGasUsed': 21000, 'from': '0xA1E4380A3B1f749673E270229993eE55F35663b4', 'gasUsed': 21000, 'logs': [], 'logsBloom': '0x000000000000000000000000000000000000000000000000...0000', 'status': 1, # 0 or 1 'to': '0x5DF9B87991262F6BA471F09758CDE1c0FC1De734', 'transactionHash': '0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060', 'transactionIndex': 0,})Eth.get_transaction_count(account, block_identifier=web3.eth.default_block)Delegates to eth_getTransactionCount RPC MethodReturns the number of transactions that have been sent from account asof the block specified by block_identifier.account may be a checksum address or an ENS name>>> web3.eth.get_transaction_count('0xd3CdA913deB6f67967B99D67aCDFa1712C293601')340Eth.send_transaction(transaction)Delegates to eth_sendTransaction RPC MethodSigns and sends the given transactionThe transaction parameter should be a dictionary with the following fields.from: bytes or text, checksum address or ENS name - (optional, default:web3.eth.defaultAccount) The address the transaction is sent from.to: bytes or text, checksum address or ENS name - (optional when creating newcontract) The address the transaction is directed to.gas: integer - (optional) Integer of the gasprovided for the transaction execution. It will return unused gas.maxFeePerGas: integer or hex - (optional) maximum amount you’re willingto pay, inclusive of baseFeePerGas and maxPriorityFeePerGas. The differencebetween maxFeePerGas and baseFeePerGas + maxPriorityFeePerGas is refundedto the
Add Comment