blockscout-python
Python API for blockscout.com as currently tested on:
REST Endpoints
The following REST endpoints are provided:
Accounts (source) (test notebook)
get_addressesget_address_infoget_address_countersget_address_transactionsget_address_logsget_blocks_validatedget_token_balancesget_token_balances_with_filteringget_coin_balance_historyget_coin_balance_history_by_day
Block (source) (test notebook)
get_block_infoget_block_transactionsget_block_withdrawalsget_main_page_blocks
Contract (source) (test notebook)
get_smart_contractsget_smart_contract_countersget_smart_contract
Tokens (source) (test notebook)
get_tokens_listget_token_infoget_token_transfersget_token_holdersget_token_counters
Transactions (source) (test notebook)
get_state_changesget_transaction_logsget_internal_transactionsget_token_hash_transfersget_transaction_infoget_main_page_transactions
RPC Endpoints
The following RPC endpoints are provided:
Accounts (source) (test notebook)
get_balanceget_pending_txs_by_address_paginatedget_txs_by_address_paginatedget_erc20_token_transfer_events_by_addressget_erc721_token_transfer_events_by_addressget_erc20_balance_by_contract_addressget_erc20_tokens_by_addressget_account_list_balances
Block (source) (test notebook)
get_block_reward_by_block_numberget_est_block_countdown_time_by_block_numberget_block_number_by_timestamp
Contract (source) (test notebook)
get_contract_listget_contract_abiget_source_codeget_contract_creation
Stats (source) (test notebook)
get_total_token_supplyget_total_eth_supplyget_total_coin_supplyget_eth_priceget_coin_price
Tokens (source) (test notebook)
get_total_supply_by_contract_addressget_total_holders_by_contract_addressget_tx_infoget_tx_receipt_statusget_status
Installation
Install from source:
pip install git+https://github.com/defipy-devs/blockscout-python.git
Alternatively, install from PyPI:
pip install blockscout-python
Basic Usage
from blockscout import Blockscout
from blockscout import Net
eth = Blockscout(Net.ROLLUX, API.RPC)
Then you can call all available methods, e.g.:
eth.get_balance(address="0xBb8b9456F615545c88528653024E87C6069d1598")
> {'message': 'OK', 'result': '2010991698475838058402243', 'status': '1'}
Token Transfers: Time Series
- See test notebook for example
Pull data for specified address
from blockscout import TokenTransfers
from blockscout import Net
addr = '0x8A4AA176007196D48d39C89402d3753c39AE64c1'
tkn_trans = TokenTransfers(Net.ROLLUX)
dict_transfers = tkn_trans.apply(addr)
tkn_balances = tkn_trans.get_tkn_balances()
tkn_balances
OUTPUT:
{'USDT': {'tkn_balance': 89590009236, 'tkn_decimal': 6},
'USDC': {'tkn_balance': 238003477125, 'tkn_decimal': 6},
'ETH': {'tkn_balance': 2689089808644384766235, 'tkn_decimal': 18},
'BTC': {'tkn_balance': 999799972, 'tkn_decimal': 8},
'WSYS': {'tkn_balance': 65787771636449164370510, 'tkn_decimal': 18}}
Plot token transfers
import matplotlib.pyplot as plt
tkn_symbol = 'USDC'
dates, tkn_coin_balances = tkn_trans.get_tkn_timeseries(dict_transfers, tkn_symbol)
fig, (TKN_ax) = plt.subplots(nrows=1, sharex=False, sharey=False, figsize=(16, 3))
TKN_ax.plot(dates, tkn_coin_balances, color = 'r',linestyle = 'dashdot', label=tkn_symbol)
TKN_ax.set_ylabel(f'{tkn_symbol} Balance', size=14)
TKN_ax.set_xlabel('Date', size=14)
Coin Transfers: Time Series
- See test notebook for example
Pull data for specified address
from blockscout import CoinTransfers
from blockscout import Net
addr = '0x8A4AA176007196D48d39C89402d3753c39AE64c1'
coin_trans = CoinTransfers(Net.ROLLUX)
txs = coin_trans.pull_coin_transactions(addr)
coin_tx = coin_trans.pull_coin_balances(addr, txs)
Plot token transfers
import matplotlib.pyplot as plt
tkn_symbol = 'SYS'
dates, tkn_coin_balances = coin_trans.get_tkn_timeseries(coin_tx)
fig, (TKN_ax) = plt.subplots(nrows=1, sharex=False, sharey=False, figsize=(16, 3))
TKN_ax.plot(dates, tkn_coin_balances, color = 'r',linestyle = 'dashdot', label=tkn_symbol)
TKN_ax.set_ylabel(f'{tkn_symbol} Balance', size=14)
TKN_ax.set_xlabel('Date', size=14)
If you found this package helpful, please leave a :star:!
Powered by Blockscout.com APIs.
Metadata
Release files for blockscout-python 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| blockscout_python-0.1.2.tar.gz | 15.2 kB | Without provenance | Details for blockscout_python-0.1.2.tar.gz |
Release files / blockscout_python-0.1.2.tar.gz
| Download URL | blockscout_python-0.1.2.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c60ff4aff2aa67d318cbd8f6b72a97c684d708e1d1b486dc40ae0f49ff8cc80
|
|
BLAKE2b-256 checksum How to use checksums |
ee09db0b89964179b5c612b387c7da4b36861851d5dac6858a3543e547141fdf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.0rc2
|
Security for blockscout-python 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.