用于数据收集的强大Python包装器over Etherscan API。
etherscan-p的Python项目详细描述
用于数据收集的强大Python包装器over Etherscan API。在
说明
Etherscan API在端点之间存在各种不一致性,例如值的编码(十六进制与base10)以及返回的数据结构。该模块简化并标准化了从Etherscan返回的数据结构,并提供了性能改进,如查询中的并行化。在
安装
要安装软件包,只需运行以下命令:
pip install etherscan_py
使用
要使用该包,请使用您的Etherscan API密钥初始化客户端。在
^{pr2}$数据结构
基本的Etherscan事件数据结构。在
class EtherscanEvent: address: string topics: [string] data: string block_height: int timestamp: int gas_price: int gas_used: int logindex: int txhash: string
基本的Etherscan事件数据结构,以及导致事件发出的关联事务的附加信息。在
class EnrichedEvent(EtherscanEvent): address: string topics: [string] data: string block_height: int timestamp: int gas_price: int gas_used: int logindex: int txhash: string from_address: string to_address: string tx_input: string nonce: int position_in_block: int value: int
基本的Etherscan事务数据结构。在
class EtherscanTransaction: txhash: string block_height: int timestamp: int nonce: int from_address: string to_address: string value: int gas_price: int tx_input: string position_in_block: int is_error: bool
方法
以下是支持的方法:
{1}$ .. 代码块:
>>> client.get_eth_price() >>> 229.16
在get_latest_block_height() .. 代码块:
>>> client.get_latest_block_height() >>> 10309928
在get_first_tx_block(address) .. 代码块:
>>> client.get_first_tx_block('0x27054b13b1B798B345b591a4d22e6562d47eA75a') >>> 4352086
在get_tx_by_hash(txhash) .. 代码块:
>>> res = client.get_tx_by_hash('0xb8b56002413bb6b8a0fbf7f986715a297d678ecfc4fdcd0b37d9a88048e5c68e') >>> res.txhash >>> '0xb8b56002413bb6b8a0fbf7f986715a297d678ecfc4fdcd0b37d9a88048e5c68e'
在get_all_events(address, topic, enriched_data=False, from_block=0, to_block='latest', thread_count=1)
>>> res = client.get_all_events( address = '0x51c72befae54d365a9d0c08c486aee4f99285e08', topic = '0x56f54e5e291f84831023c9ddf34fe42973dae320af11193db2b5f7af27719ba6' ) >>> len(res) >>> 72
在get_all_transactions(from_address, status, to_address='',fn_signature='', from_block=0, to_block='latest', thread_count=1)
status is either 0,1 or 2.
0: Failed 1: Successful 2: Both fn_signature is the first 10-characters of a tx's input_data
>>> res = client.get_all_transactions( from_address = '0x274CeA454c35b6bB3fE07377E719e45dF9E3Cac6', status = 2, to_address = '0x51c72befae54d365a9d0c08c486aee4f99285e08' ) >>> len(res) >>> 14
在
- 项目
标签: