Transactions
Examples
Note
These examples are crafted as a Jupyter notebook. You can download the original notebook file here.
Also note that inside Jupyter notebooks, await
can be used freely outside of asyncio.run()
.
In [1]:
import ctc
In [2]:
transaction_hash = '0x6ff0860e202c61189cb2a3a38286bffd694acbc50577df6cb5a7ff40e21ea074'
address = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045'
Get transaction by hash¶
In [3]:
transaction = await ctc.async_get_transaction(transaction_hash)
transaction
Out[3]:
{'block_hash': '0xb7ae60b456f7733ae3d8bb927b03470eb662f0285f6c83d545b735c35634ede3', 'block_number': 318528, 'hash': '0x6ff0860e202c61189cb2a3a38286bffd694acbc50577df6cb5a7ff40e21ea074', 'from': '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 'gas': 530000, 'gas_price': 50000000000, 'input': '0x5a9809ed000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000005ed8cee6b63b1c6afce3ad7c92f4fd7e1b8fad9f00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000001b48eb57e00000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001db3439a222c519ab44bb1144fc28167b4fa6ee600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 'nonce': 0, 'r': '0x76e2003e065da19c06351639b48624b7d7ac65c74c76370668d544dee730dd79', 's': '0x4a25a8abc8e55a4c254d5019aea129bf02aee6e7a40438c26c83149719ade58f', 'to': '0x7e2d0fe0ffdd78c264f8d40d19acb7d04390c6e8', 'transaction_index': 1, 'type': '0x0', 'v': 27, 'value': 120000000000000}
Get transaction count of address¶
In [4]:
transaction_count = await ctc.async_get_transaction_count(address)
transaction_count
Out[4]:
892
Get all transactions from address¶
In [5]:
transactions = await ctc.async_get_transactions_from_address(address)
transactions[0]
Out[5]:
{'block_hash': '0xb7ae60b456f7733ae3d8bb927b03470eb662f0285f6c83d545b735c35634ede3', 'block_number': 318528, 'hash': '0x6ff0860e202c61189cb2a3a38286bffd694acbc50577df6cb5a7ff40e21ea074', 'from': '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 'gas': 530000, 'gas_price': 50000000000, 'input': '0x5a9809ed000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000005ed8cee6b63b1c6afce3ad7c92f4fd7e1b8fad9f00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000001b48eb57e00000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001db3439a222c519ab44bb1144fc28167b4fa6ee600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 'nonce': 0, 'r': '0x76e2003e065da19c06351639b48624b7d7ac65c74c76370668d544dee730dd79', 's': '0x4a25a8abc8e55a4c254d5019aea129bf02aee6e7a40438c26c83149719ade58f', 'to': '0x7e2d0fe0ffdd78c264f8d40d19acb7d04390c6e8', 'transaction_index': 1, 'type': '0x0', 'v': 27, 'value': 120000000000000}
Reference
- async ctc.evm.async_get_transaction(transaction_hash)
get transaction
- async ctc.evm.async_get_transaction_count(address)
get transaction count of address