EVM Blockexplorer API Tutorial
This tutorial aims to be a quick guide to get you started using the Etherscan API integrated into messari’s python library.
[2]:
import time #need to sleep to stop rate limiting
#from messari.blockexplorers.etherscan import Etherscan
from messari.blockexplorers import Etherscan
API_KEY='your_api_key'
es = Etherscan(api_key=API_KEY)
API Structure
The Deep DAO Python client contains a number of functions that wrap some of Deep DAO’s API endpoints. These include:
Accounts
get_account_ether_balance
get_account_normal_transactions
get_account_internal_transactions
get_transaction_internal_transactions
get_block_range_internal_transactions
get_account_token_transfers
get_account_nft_transfers
get_account_blocks_mined
Contracts
get_contract_abi
get_contract_source_code
Transactions
get_contract_execution_status
get_transaction_execution_status
Blocks
get_block_reward
get_block_countdown
get_block_by_timestamp
Logs
get_logs
Geth/Parity Proxy
get_eth_block_number
get_eth_block
get_eth_uncle
get_eth_block_transaction_count
get_eth_transaction_by_hash
get_eth_transaction_by_block_index
get_eth_account_transaction_count
get_eth_transaction_reciept
get_eth_gas_price
Tokens
get_token_total_supply
get_token_account_balance
Gas Tracker
get_est_confirmation
get_gas_oracle
Stats
get_total_eth_supply
get_total_eth2_supply
get_last_eth_price
get_nodes_size
get_total_nodes_count
Below are a few examples to showcase the functionality and types of data each function generates.
Accounts
Functions to return info about given account(s)
[2]:
accounts = ['0xBa19BdFF99065d9ABF3dF8CE942390B97fd71B12', '0x503e4bfe8299D486701BC7bc7F2Ea94f50035daC']
txns = ['0x29f2df8ce6a0e2a93bddacdfcceb9fd847630dcd1d25ad1ec3402cc449fa1eb6', '0x0bd7f9af4f8ddb18a321ab0120a2389046b39feb67561d17378e0d4dc062decc', '0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787e341eea230614e49ff61']
tokens = ['0x1f9840a85d5af5bf1d1762f925bdaddc4201f984', '0xc18360217d8f7ab5e7c516566761ea12ce7f9d72']
get_account_ether_balance
Returns the Ether (wei) balance of a given address
[3]:
account_balances = es.get_account_native_balance(accounts)
time.sleep(1)
account_balances
[3]:
balances | |
---|---|
0xBa19BdFF99065d9ABF3dF8CE942390B97fd71B12 | 976947792508781600 |
0x503e4bfe8299D486701BC7bc7F2Ea94f50035daC | 2239319013287287 |
get_account_normal_transactions
Returns the list of transactions performed by an address, with optional pagination
[4]:
account_normal = es.get_account_normal_transactions(accounts)
time.sleep(1)
account_normal.head()
[4]:
0xBa19BdFF99065d9ABF3dF8CE942390B97fd71B12 | ... | 0x503e4bfe8299D486701BC7bc7F2Ea94f50035daC | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
blockNumber | timeStamp | hash | nonce | blockHash | transactionIndex | from | to | value | gas | ... | value | gas | gasPrice | isError | txreceipt_status | input | contractAddress | cumulativeGasUsed | gasUsed | confirmations | |
0 | 12150458 | 1617238173 | 0x1d3e049fcaeb7e02dbd1c796852fd2a0accb584eb621... | 34 | 0xc5a9897f311d4310e0d6701ed50d24d81640a96fa54b... | 113 | 0x503e4bfe8299d486701bc7bc7f2ea94f50035dac | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 150000000000000000 | 21000 | ... | 200000000000000000 | 21000 | 100000000000 | 0 | 1 | 0x | 12485187 | 21000 | 1766673 | |
1 | 12150499 | 1617238663 | 0x7be0198fc6afc4227aa63eed7b04e3c2e1cb845f77b7... | 10 | 0x32b9419d095d0d6031498dac7b86844536db45b210be... | 161 | 0xe35e8e145745df95d38d2ae1d2091c9097962e0d | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 150000000000000000 | 21000 | ... | 170000000000000000 | 170000 | 122200966918 | 0 | 1 | 0x7ff36ab5000000000000000000000000000000000000... | 2220434 | 124771 | 1766661 | |
2 | 12150534 | 1617239068 | 0xfc70483d8711be918fbf2b78d37d27ec46c7dc7338dc... | 0 | 0xa70a5f5aaf4d389b9c6150b850a20041077c7ff757c0... | 42 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x4678f0a6958e4d2bc4f1baf7bc52e8f3564f3fe4 | 0 | 918027 | ... | 1000000000000000000 | 21000 | 117000000000 | 0 | 1 | 0x | 11686985 | 21000 | 1766520 | |
3 | 12150547 | 1617239178 | 0x409ddb1a7f518fef0d1225e118166cc05c7cd28e369a... | 1 | 0x7c2c028e6c4dfbdaaf9364c75a10efc92a4a7e1168bb... | 44 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x2260fac5e5542a773aa44fbcfedf7c193bc2c599 | 0 | 70165 | ... | 990000000000000000 | 170000 | 124772370792 | 0 | 1 | 0x7ff36ab5000000000000000000000000000000000000... | 316200 | 109771 | 1766494 | |
4 | 12150591 | 1617239881 | 0x091bfeb699eb8822e68b7c572a458e72cd5bd23b8e53... | 12 | 0x5dfd2dc6544b3928053da118dd744159c77785d42792... | 105 | 0xe35e8e145745df95d38d2ae1d2091c9097962e0d | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 100000000000000000 | 21000 | ... | 4900000000000000000 | 21000 | 115000000000 | 0 | 1 | 0x | 8774834 | 21000 | 1754228 |
5 rows × 36 columns
get_account_internal_transactions
Returns the list of internal transactions performed by an address, with optional pagination
[5]:
account_internal = es.get_account_internal_transactions(accounts)
time.sleep(1)
account_internal.head()
[5]:
0xBa19BdFF99065d9ABF3dF8CE942390B97fd71B12 | ... | 0x503e4bfe8299D486701BC7bc7F2Ea94f50035daC | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
blockNumber | timeStamp | hash | from | to | value | contractAddress | input | type | gas | ... | to | value | contractAddress | input | type | gas | gasUsed | traceId | isError | errCode | |
0 | 12163335 | 1617409597 | 0x68141c1316d922ed5113e265a5d636f1ec6b090e7ea7... | 0x283af0b28c62c092c9727f1ee09c02ca627eb7f5 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 1132216169560432 | call | 2300 | ... | 0x503e4bfe8299d486701bc7bc7f2ea94f50035dac | 1378007072137347 | call | 2300 | 0 | 10 | 0 | |||||
1 | 12290519 | 1619100967 | 0x82785446d28889f99d95139610abc5bdd0362be3f302... | 0xe68fff06277508259b1229d284120488d4ded390 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 195917915000000000 | call | 9445 | ... | 0x503e4bfe8299d486701bc7bc7f2ea94f50035dac | 1269277206626259375 | call | 44313 | 0 | 2 | 0 | |||||
2 | 12358348 | 1620006583 | 0xd86114bde57cd4587d98ca24be129299a3d29d60bca7... | 0x0f92496ff3997d8911b42dc87cd71c29493c2efa | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 1500000000000000000 | call | 2300 | ... | 0x503e4bfe8299d486701bc7bc7f2ea94f50035dac | 924987209833558520 | call | 17389 | 0 | 4 | 0 | |||||
3 | 12361579 | 1620049473 | 0xec5a0beb745af0dc51f85c767f5267308501c991091a... | 0x7a250d5630b4cf539739df2c5dacb4c659f2488d | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 1000000000000000000 | call | 26093 | ... | 0x503e4bfe8299d486701bc7bc7f2ea94f50035dac | 2915551216325263181 | call | 29846 | 0 | 0_4 | 0 | |||||
4 | 12361931 | 1620054041 | 0xcffe026fe4efb0d0fbb71ef0a23f756d33d41878e2fb... | 0x1db681925786441ba82adefac7bf492089665ca0 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 632281841566148913 | call | 2300 | ... | 0x503e4bfe8299d486701bc7bc7f2ea94f50035dac | 1124184601060627798 | call | 2300 | 0 | 0 | 0 |
5 rows × 28 columns
get_transaction_internal_transactions
Returns the list of internal transactions performed within a transaction
[6]:
int_txn = '0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170'
transaction_internals = es.get_transaction_internal_transactions(int_txn)
time.sleep(1)
transaction_internals
[6]:
0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
blockNumber | timeStamp | from | to | value | contractAddress | input | type | gas | gasUsed | isError | errCode | |
0 | 1743059 | 1466489498 | 0x2cac6e4b11d6b58f6d3c1c9d5fe8faa89f60e5a2 | 0x66a1c3eaf0f1ffc28d209c0763ed0ca614f3b002 | 7106740000000000 | call | 2300 | 0 | 0 |
get_block_range_internal_transactions
Returns the list of internal transactions performed within a block range, with optional pagination
[7]:
block_range_internals = es.get_block_range_internal_transactions(10000000,10001000)
time.sleep(1)
block_range_internals.head()
[7]:
blockNumber | timeStamp | hash | from | to | value | contractAddress | input | type | gas | gasUsed | traceId | isError | errCode | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 10000000 | 1588598533 | 0xc2f74145a896b6a5b938216d130f5c382d3d77d5d501... | 0xf0542ed44d268c85875b3b84b0e7ce0773e9aeef | 0x35e4876102389f13d78381d317ff4612412a56c9 | 50000000000000000 | call | 2300 | 0 | 0 | 0 | |||
1 | 10000000 | 1588598533 | 0xa9b04ff42f93868886c1258ba59967ceb6aafa011865... | 0x8a91c9a16cd62693649d80afa85a09dbbdcb8508 | 0 | 0xbce5fe052b25e422550f6012fdd1941f9353f001 | create | 1499696 | 64779 | 0 | 0 | |||
2 | 10000000 | 1588598533 | 0xc96ee63d87a2d21b1dccff4d3de50726887cadbf010c... | 0x8a91c9a16cd62693649d80afa85a09dbbdcb8508 | 0 | 0x1f52775214e2b3d099eb82b6e9e9025c490157ad | create | 1877196 | 64779 | 0 | 0 | |||
3 | 10000000 | 1588598533 | 0x46a9ce0dbc787533c6bda878ff3c4f2354b86301bf4f... | 0x8a91c9a16cd62693649d80afa85a09dbbdcb8508 | 0 | 0x2858e866c5fdcefea13bedf13948a785b5c8b040 | create | 1877196 | 64779 | 0 | 0 | |||
4 | 10000000 | 1588598533 | 0x9dab17b59a0612347929fe03bb82d6a03f8a0880ac62... | 0x8a91c9a16cd62693649d80afa85a09dbbdcb8508 | 0 | 0x903171964ee615dc99f350bd29ea747b887ae3f4 | create | 1897522 | 64779 | 1 | 0 |
get_account_token_transfers
Returns the list of ERC-20 tokens transferred by an address, with optional filtering by token contract
[8]:
account_token_transfers = es.get_account_token_transfers(accounts)
time.sleep(1)
account_token_transfers.head()
[8]:
0xBa19BdFF99065d9ABF3dF8CE942390B97fd71B12 | ... | 0x503e4bfe8299D486701BC7bc7F2Ea94f50035daC | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
blockNumber | timeStamp | hash | nonce | blockHash | from | contractAddress | to | value | tokenName | ... | tokenName | tokenSymbol | tokenDecimal | transactionIndex | gas | gasPrice | gasUsed | cumulativeGasUsed | input | confirmations | |
0 | 12150499 | 1617238663 | 0x1680acc117e0a9bfa7e24553c11a6ca133a1c708a677... | 35 | 0x32b9419d095d0d6031498dac7b86844536db45b210be... | 0x503e4bfe8299d486701bc7bc7f2ea94f50035dac | 0x2260fac5e5542a773aa44fbcfedf7c193bc2c599 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 25282582 | Wrapped BTC | ... | DefiPulse Index | DPI | 18 | 29 | 170000 | 122200966918 | 124771 | 2220434 | deprecated | 1766661 |
1 | 12150506 | 1617238752 | 0x42595019ce981395f8e92ebf645989527a8537d71aab... | 11 | 0x4eb37fcc85990d4eebd746e9a78b014d3093a49aaf56... | 0xe35e8e145745df95d38d2ae1d2091c9097962e0d | 0x2260fac5e5542a773aa44fbcfedf7c193bc2c599 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 8604978 | Wrapped BTC | ... | DefiPulse Index | DPI | 18 | 7 | 170000 | 124772370792 | 109771 | 316200 | deprecated | 1766494 |
2 | 12150615 | 1617240099 | 0x23ea85829b0d9f78ce79ae543411252793a60ac93e67... | 2 | 0xd0e73d1b266d43c767a5ff9989da25fda414b9a40326... | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x2260fac5e5542a773aa44fbcfedf7c193bc2c599 | 0x0f92496ff3997d8911b42dc87cd71c29493c2efa | 33880000 | Wrapped BTC | ... | Interest Bearing ETH | ibETH | 18 | 89 | 137074 | 117000000000 | 91383 | 7411688 | deprecated | 1754195 |
3 | 12150615 | 1617240099 | 0x23ea85829b0d9f78ce79ae543411252793a60ac93e67... | 2 | 0xd0e73d1b266d43c767a5ff9989da25fda414b9a40326... | 0x0000000000000000000000000000000000000000 | 0x6b175474e89094c44da98b954eedeac495271d0f | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 10000000000000000000000 | Dai Stablecoin | ... | Interest Bearing ETH | ibETH | 18 | 77 | 114058 | 130000000000 | 76039 | 8219729 | deprecated | 1748600 |
4 | 12150678 | 1617240821 | 0xcb1d2301f1ca5d697c150539276eb914ada713211011... | 4 | 0x207f158eb9443f3867dbb8ea7d28cf7732d6393472b7... | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x6b175474e89094c44da98b954eedeac495271d0f | 0xa478c2975ab1ea89e8196811f51a7b7ade33eb11 | 10000000000000000000000 | Dai Stablecoin | ... | Curve DAO Token | CRV | 18 | 149 | 164925 | 131500000000 | 124363 | 10406728 | deprecated | 1721161 |
5 rows × 38 columns
get_account_nft_transfers
Returns the list of ERC-721 ( NFT ) tokens transferred by an address, with optional filtering by token contract
[9]:
account_nft_transfers = es.get_account_nft_transfers(accounts)
time.sleep(1)
account_nft_transfers.head()
[9]:
0xBa19BdFF99065d9ABF3dF8CE942390B97fd71B12 | ... | 0x503e4bfe8299D486701BC7bc7F2Ea94f50035daC | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
blockNumber | timeStamp | hash | nonce | blockHash | from | contractAddress | to | tokenID | tokenName | ... | tokenName | tokenSymbol | tokenDecimal | transactionIndex | gas | gasPrice | gasUsed | cumulativeGasUsed | input | confirmations | |
0 | 12163335 | 1617409597 | 0x68141c1316d922ed5113e265a5d636f1ec6b090e7ea7... | 7 | 0x50410977c4200551881195a8a82dc774f1ad856d1486... | 0x283af0b28c62c092c9727f1ee09c02ca627eb7f5 | 0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 4330337349596085516852643297037585621539016595... | Ethereum Name Service | ... | Ethereum Name Service | ENS | 0 | 141 | 316737 | 104000000000 | 274305 | 9723492 | deprecated | 1733496 |
1 | 13105774 | 1630044146 | 0xafeac0a71b170dc37ee03b12b6b063c930de3008986f... | 154 | 0x06a55da3c1917d3401d32386e2e0ba931301363d2f63... | 0x0000000000000000000000000000000000000000 | 0xdc8bed466ee117ebff8ee84896d6acd42170d4bb | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 1014 | Non-Fungible Soup | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2 | 13105774 | 1630044146 | 0xafeac0a71b170dc37ee03b12b6b063c930de3008986f... | 154 | 0x06a55da3c1917d3401d32386e2e0ba931301363d2f63... | 0x0000000000000000000000000000000000000000 | 0xdc8bed466ee117ebff8ee84896d6acd42170d4bb | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 1585 | Non-Fungible Soup | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
3 | 13105774 | 1630044146 | 0xafeac0a71b170dc37ee03b12b6b063c930de3008986f... | 154 | 0x06a55da3c1917d3401d32386e2e0ba931301363d2f63... | 0x0000000000000000000000000000000000000000 | 0xdc8bed466ee117ebff8ee84896d6acd42170d4bb | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 108 | Non-Fungible Soup | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
4 | 13108127 | 1630076779 | 0xa63f272d0089e3c0f3af4f11a817dacda9a203e35bb1... | 155 | 0xa9e53c0bc8f6abb2c5e1a8c73d5ea7e7b4528d872834... | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0xdc8bed466ee117ebff8ee84896d6acd42170d4bb | 0x07bbf9fdb156f298bec53cefa3652954a0738ed1 | 1585 | Non-Fungible Soup | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
5 rows × 38 columns
get_account_blocks_mined
Returns the list of blocks mined by an address
[2]:
# Ethermine pubkey, F2Pool Old pubkey
miners = ['0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8', '0x829BD824B016326A401d083B33D092293333A830']
account_blocks_mined = es.get_account_blocks_mined(miners)
time.sleep(1)
account_blocks_mined.head()
[2]:
0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8 | 0x829BD824B016326A401d083B33D092293333A830 | |||||
---|---|---|---|---|---|---|
blockNumber | timeStamp | blockReward | blockNumber | timeStamp | blockReward | |
0 | 13930693 | 1641188358 | 2082764318928026917 | 13930692 | 1641188354 | 2026197939084862035 |
1 | 13930687 | 1641188310 | 2000000000000000000 | 13930688 | 1641188311 | 2137050444256578152 |
2 | 13930685 | 1641188282 | 2044603599365499508 | 13930686 | 1641188295 | 2087861421208960766 |
3 | 13930680 | 1641188228 | 2071377567715645856 | 13930684 | 1641188266 | 2163025280071299245 |
4 | 13930678 | 1641188174 | 2257598001084298849 | 13930672 | 1641188138 | 2023575067970603989 |
Contracts
Functions to return information about contracts
[11]:
# Sushiswap Router, Ygov Contract
contracts = ['0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F', '0x0001FB050Fe7312791bF6475b96569D83F695C9f']
get_contract_abi
Returns the Contract Application Binary Interface (ABI) of a verified smart contract
[12]:
abis = es.get_contract_abi(contracts)
time.sleep(1)
abis
[12]:
{'0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F': '[{"inputs":[{"internalType":"address","name":"_factory","type":"address"},{"internalType":"address","name":"_WETH","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint256","name":"amountADesired","type":"uint256"},{"internalType":"uint256","name":"amountBDesired","type":"uint256"},{"internalType":"uint256","name":"amountAMin","type":"uint256"},{"internalType":"uint256","name":"amountBMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"addLiquidity","outputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"amountB","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amountTokenDesired","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"addLiquidityETH","outputs":[{"internalType":"uint256","name":"amountToken","type":"uint256"},{"internalType":"uint256","name":"amountETH","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"reserveIn","type":"uint256"},{"internalType":"uint256","name":"reserveOut","type":"uint256"}],"name":"getAmountIn","outputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"reserveIn","type":"uint256"},{"internalType":"uint256","name":"reserveOut","type":"uint256"}],"name":"getAmountOut","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"getAmountsIn","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"getAmountsOut","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"reserveA","type":"uint256"},{"internalType":"uint256","name":"reserveB","type":"uint256"}],"name":"quote","outputs":[{"internalType":"uint256","name":"amountB","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountAMin","type":"uint256"},{"internalType":"uint256","name":"amountBMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidity","outputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"amountB","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidityETH","outputs":[{"internalType":"uint256","name":"amountToken","type":"uint256"},{"internalType":"uint256","name":"amountETH","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidityETHSupportingFeeOnTransferTokens","outputs":[{"internalType":"uint256","name":"amountETH","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bool","name":"approveMax","type":"bool"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"removeLiquidityETHWithPermit","outputs":[{"internalType":"uint256","name":"amountToken","type":"uint256"},{"internalType":"uint256","name":"amountETH","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bool","name":"approveMax","type":"bool"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"removeLiquidityETHWithPermitSupportingFeeOnTransferTokens","outputs":[{"internalType":"uint256","name":"amountETH","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountAMin","type":"uint256"},{"internalType":"uint256","name":"amountBMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bool","name":"approveMax","type":"bool"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"removeLiquidityWithPermit","outputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"amountB","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapETHForExactTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactETHForTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactETHForTokensSupportingFeeOnTransferTokens","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForETH","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForETHSupportingFeeOnTransferTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForTokensSupportingFeeOnTransferTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"amountInMax","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapTokensForExactETH","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"amountInMax","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapTokensForExactTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]',
'0x0001FB050Fe7312791bF6475b96569D83F695C9f': '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"constant":true,"inputs":[],"name":"DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"exit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"getReward","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastTimeRewardApplicable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"reward","type":"uint256"}],"name":"notifyRewardAmount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"periodFinish","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rewardRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_rewardDistribution","type":"address"}],"name":"setRewardDistribution","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userRewardPerTokenPaid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"y","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"yfi","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}]'}
get_contract_source_code
Returns the Solidity source code of a verified smart contract
[13]:
source_code = es.get_contract_source_code(contracts)
time.sleep(1)
source_code
[13]:
0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F | ... | 0x0001FB050Fe7312791bF6475b96569D83F695C9f | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SourceCode | ABI | ContractName | CompilerVersion | OptimizationUsed | Runs | ConstructorArguments | EVMVersion | Library | LicenseType | ... | CompilerVersion | OptimizationUsed | Runs | ConstructorArguments | EVMVersion | Library | LicenseType | Proxy | Implementation | SwarmSource | |
0 | // File: contracts/uniswapv2/interfaces/IUnisw... | [{"inputs":[{"internalType":"address","name":"... | UniswapV2Router02 | v0.6.12+commit.27d51765 | 1 | 200 | 000000000000000000000000c0aee478e3658e2610c5f7... | Default | None | ... | v0.5.16+commit.9c3226ce | 0 | 200 | Default | MIT | 0 | bzzr://e51af10bf74bebc919ec3e43a0470cbc7433a40... |
1 rows × 26 columns
Transactions
Functions to return information about transactions
[14]:
txns = ['0x29f2df8ce6a0e2a93bddacdfcceb9fd847630dcd1d25ad1ec3402cc449fa1eb6', '0x0bd7f9af4f8ddb18a321ab0120a2389046b39feb67561d17378e0d4dc062decc', '0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787e341eea230614e49ff61']
get_contract_execution_status – busted on Etherscan backend
Returns the status code of a contract execution
[15]:
contract_execution_status = es.get_contract_execution_status(txns)
time.sleep(1)
contract_execution_status
[15]:
transactions | |
---|---|
0x29f2df8ce6a0e2a93bddacdfcceb9fd847630dcd1d25ad1ec3402cc449fa1eb6 | Error! Missing Or invalid Action name |
0x0bd7f9af4f8ddb18a321ab0120a2389046b39feb67561d17378e0d4dc062decc | Error! Missing Or invalid Action name |
0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787e341eea230614e49ff61 | Error! Missing Or invalid Action name |
get_transaction_execution_status – busted on Etherscan backend
Returns the status code of a transaction execution.
[16]:
transaction_execution_status = es.get_transaction_execution_status(txns)
time.sleep(1)
transaction_execution_status
[16]:
transactions | |
---|---|
0x29f2df8ce6a0e2a93bddacdfcceb9fd847630dcd1d25ad1ec3402cc449fa1eb6 | Error! Missing Or invalid Action name |
0x0bd7f9af4f8ddb18a321ab0120a2389046b39feb67561d17378e0d4dc062decc | Error! Missing Or invalid Action name |
0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787e341eea230614e49ff61 | Error! Missing Or invalid Action name |
Blocks
Functions to return information about given block(s)
[2]:
blocks = [13188647, 13088500]
far_out_block = 50000000
timestamp = 1638767557
get_block_reward
Returns the block reward and ‘Uncle’ block rewards
[18]:
block_rewards = es.get_block_reward(blocks)
time.sleep(1)
block_rewards
[18]:
13188647 | 13088500 | |
---|---|---|
blockNumber | 13188647 | 13088500 |
timeStamp | 1631151375 | 1629814354 |
blockMiner | 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c | 0x1ad91ee08f21be3de0ba2ba6918e714da6b45836 |
blockReward | 2747824941203436716 | 2431595650457815561 |
uncles | [] | [] |
uncleInclusionReward | 0 | 0 |
get_block_countdown
Returns the estimated time remaining, in seconds, until a certain block is mined
[19]:
block_countdown = es.get_block_countdown(far_out_block)
time.sleep(1)
block_countdown
[19]:
CurrentBlock | CountdownBlock | RemainingBlock | EstimateTimeInSec | |
---|---|---|---|---|
0 | 13761567 | 50000000 | 36238433 | 496466547.1 |
get_block_by_timestamp
Returns the block number that was mined at a certain timestamp (in unix)
[20]:
block_at_time = es.get_block_by_timestamp(timestamp)
time.sleep(1)
block_at_time
[20]:
0 | |
---|---|
0 | 13750384 |
Logs
This function is a wrapper around the Etherscan API which is a wrapper around the native eth_getLogs. Please check out their documentation for a more in depth explanation: https://docs.etherscan.io/api-endpoints/logs
Below are the list of supported filter parameters: * fromBlock, toBlock, address * topic0, topic1, topic2, topic3 (32 Bytes per topic) * topic0_1_opr (and|or between topic0 & topic1), topic1_2_opr (and|or between topic1 & topic2), topic2_3_opr (and|or between topic2 & topic3), topic0_2_opr (and|or between topic0 & topic2), topic0_3_opr (and|or between topic0 & topic3), topic1_3_opr (and|or between topic1 & topic3)
Some parameters to take note of: * FromBlock & ToBlock accepts the blocknumber (integer, NOT hex) or ‘latest’ (earliest & pending is NOT supported yet) * Topic Operator (opr) choices are either ‘and’ or ‘or’ and are restricted to the above choices only * FromBlock & ToBlock parameters are required * An address and/or topic(X) parameters are required, when multiple topic(X) parameters are used the topicX_X_opr (and|or operator) is also required
[21]:
address = '0x33990122638b9132ca29c723bdf037f1a891a70c'
fromBlock=379224
toBlock='latest'
topic0='0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545'
[22]:
logs = es.get_logs(address, fromBlock, to_block=toBlock, topic0=topic0)
time.sleep(1)
logs
[22]:
address | topics | data | blockNumber | timeStamp | gasPrice | gasUsed | logIndex | transactionHash | transactionIndex | |
---|---|---|---|---|---|---|---|---|---|---|
0 | 0x33990122638b9132ca29c723bdf037f1a891a70c | [0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833... | 0x | 0x5c958 | 0x561d688c | 0xba43b7400 | 0x10682 | 0x | 0x0b03498648ae2da924f961dda00dc6bb0a8df1551926... | 0x |
1 | 0x33990122638b9132ca29c723bdf037f1a891a70c | [0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833... | 0x | 0x5c965 | 0x561d6930 | 0xba43b7400 | 0x105c2 | 0x | 0x8c72ea19b48947c4339077bd9c9c09a780dfbdb1cafe... | 0x |
2 | 0x33990122638b9132ca29c723bdf037f1a891a70c | [0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833... | 0x | 0x6664c | 0x56281247 | 0xba43b7400 | 0x105c2 | 0x | 0xf9c4f7843dc1f9bf6d248ebe0033b2c51398255eb897... | 0x1 |
3 | 0x33990122638b9132ca29c723bdf037f1a891a70c | [0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833... | 0x | 0x66650 | 0x5628125d | 0xba43b7400 | 0x10642 | 0x | 0xb190139d14140cf98035c5b78fe3b2629db2787ef234... | 0x |
4 | 0x33990122638b9132ca29c723bdf037f1a891a70c | [0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833... | 0x | 0x6aff6 | 0x562cf696 | 0xba43b7400 | 0x104c2 | 0x | 0x27d96550f2b41e9bc3da7d6e2f2a333ce11c128d425b... | 0x1 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
364 | 0x33990122638b9132ca29c723bdf037f1a891a70c | [0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833... | 0x17f0b1 | 0x5742bd78 | 0x4a817c800 | 0x107c2 | 0x | 0x647676db70d8d17d4d59f27afcd048181f2dd0d6e20d... | 0x | |
365 | 0x33990122638b9132ca29c723bdf037f1a891a70c | [0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833... | 0x18df11 | 0x57502078 | 0x4a817c800 | 0x104c2 | 0x | 0xe8b0588b803621a50d4eccbb71e2f9463c0d6c267e6d... | 0x | |
366 | 0x33990122638b9132ca29c723bdf037f1a891a70c | [0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833... | 0x19741f | 0x5758741d | 0x4a817c800 | 0x10502 | 0x1 | 0x84d0668ff085c81379e0b36aa6eaf54d5d387e93084d... | 0x1 | |
367 | 0x33990122638b9132ca29c723bdf037f1a891a70c | [0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833... | 0x19749b | 0x57587a9f | 0x4a817c800 | 0xca6a | 0x3 | 0xbb60625e9c4df3cd1c66f77fb673e478c81b58deccb1... | 0x5 | |
368 | 0x33990122638b9132ca29c723bdf037f1a891a70c | [0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833... | 0x | 0x2399ec | 0x57e9bb5c | 0xba43b7400 | 0x10682 | 0x | 0x980742edcf7b5cc9e1fdb2ddd71df20a176454c09be5... | 0x |
369 rows × 10 columns
Geth/Parity Proxy
Functions to emulate a Geth/Parity Ethereum client through Etherscan
[2]:
accounts = ['0xBa19BdFF99065d9ABF3dF8CE942390B97fd71B12', '0x503e4bfe8299D486701BC7bc7F2Ea94f50035daC']
blocks = [13188647, 13088500]
index = 0
txns = ['0x29f2df8ce6a0e2a93bddacdfcceb9fd847630dcd1d25ad1ec3402cc449fa1eb6', '0x0bd7f9af4f8ddb18a321ab0120a2389046b39feb67561d17378e0d4dc062decc', '0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787e341eea230614e49ff61']
get_eth_block_number
Returns the number of most recent block
[24]:
blockNo = es.get_eth_block_number()
time.sleep(1)
blockNo
[24]:
13761569
get_eth_block
Returns information about a block by block number
[25]:
eth_block = es.get_eth_block(blocks)
time.sleep(1)
eth_block
[25]:
13188647 | 13088500 | |
---|---|---|
baseFeePerGas | 0x134742b51d | 0x1355623da4 |
difficulty | 0x1f7f67443cdcec | 0x1cb13c9b887d19 |
extraData | 0xd883010a08846765746888676f312e31362e37856c69... | 0x486976656f6e2063612d68656176792068734541 |
gasLimit | 0x1c9c380 | 0x1c9c380 |
gasUsed | 0x1c9a61f | 0xa325ef |
hash | 0x39d5dd282cb927a8a4d48067753d65d4e94cf91f161d... | 0x94fbba5b586bb7b9790fc5300f9fc3ecad1d4f5d1c94... |
logsBloom | 0xde213faebf5f4f69f195cfdbf44572ee7cf3d5d2a869... | 0x78bd33838112301d69e010cca0029a8108b0975a0084... |
miner | 0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c | 0x1ad91ee08f21be3de0ba2ba6918e714da6b45836 |
mixHash | 0x294e8047712619a370ea19ff5a4a16cd6516f508bcd8... | 0x9f9143206f0c1e3ea0ced8be5c2fd55b5a5609503bd9... |
nonce | 0x12b95eb00f016147 | 0xacfd53f2a607601b |
number | 0xc93e27 | 0xc7b6f4 |
parentHash | 0xe8bf0a48d5df068791f30aa3e5a51a512a6e6d33ad8d... | 0x6adc782254d0d211cb7260fdf921649ee990a5309d0d... |
receiptsRoot | 0x18eec39ae671cdae2d92f3cdc0e1cb873eb20cd5265f... | 0x243cb4383ddaf0b8fee03763efb69a0102e489cd6689... |
sha3Uncles | 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a... | 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a... |
size | 0x1e409 | 0xb1a1 |
stateRoot | 0xf0c8a65fc4d8913f249ab6c3269f4f14a893822f58f1... | 0xe88177015f6ef1601cda322d8830f308b33890250802... |
timestamp | 0x6139650f | 0x6124fe52 |
totalDifficulty | 0x66ac2eb3acc46c324f5 | 0x63cd38d475da8174737 |
transactions | [{'blockHash': '0x39d5dd282cb927a8a4d48067753d... | [{'blockHash': '0x94fbba5b586bb7b9790fc5300f9f... |
transactionsRoot | 0x980df7fe6c8beb9bfab65e6414a490dce743e9b55e93... | 0x93fb6db0b7354678be1b08a4769a65875d77fef756c6... |
uncles | [] | [] |
get_eth_uncle
Returns information about a uncle by block number and index
[6]:
uncle = es.get_eth_uncle(100, 0)
time.sleep(1)
uncle
get_eth_block_transaction_count
Returns the number of transactions in a block
[27]:
block_transaction_count = es.get_eth_block_transaction_count(blocks)
time.sleep(1)
block_transaction_count
[27]:
transaction_count | |
---|---|
0xc93e27 | 275 |
0xc7b6f4 | 193 |
get_eth_transaction_by_hash
Returns the information about a transaction requested by transaction hash
[28]:
txns_by_hash = es.get_eth_transaction_by_hash(txns)
time.sleep(1)
txns_by_hash
[28]:
0x29f2df8ce6a0e2a93bddacdfcceb9fd847630dcd1d25ad1ec3402cc449fa1eb6 | 0x0bd7f9af4f8ddb18a321ab0120a2389046b39feb67561d17378e0d4dc062decc | 0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787e341eea230614e49ff61 | |
---|---|---|---|
blockHash | 0xe3bfc6bb26456cc452d15fe2de6ed3931e9a0fa289dd... | 0xc26af31bcee63e11ae42d069b407f2813a7cea39669e... | 0x3ee98c172be82e1389c92f31124b5bda97e13cf4471b... |
blockNumber | 0xd09183 | 0xbd338a | 0xbe978e |
from | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 |
gas | 0x20983 | 0x72abd | 0x71541 |
gasPrice | 0x1b348f74bf | 0x14419aa600 | 0x3286353a00 |
maxFeePerGas | 0x205185d7df | NaN | NaN |
maxPriorityFeePerGas | 0x59682f00 | NaN | NaN |
hash | 0x29f2df8ce6a0e2a93bddacdfcceb9fd847630dcd1d25... | 0x0bd7f9af4f8ddb18a321ab0120a2389046b39feb6756... | 0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787... |
input | 0x3015a5b5000000000000000000000000ba19bdff9906... | 0x415565b00000000000000000000000001f9840a85d5a... | 0xf6216495000000000000000000000000dcd90c7f6324... |
nonce | 0xd4 | 0x68 | 0x79 |
to | 0xd569d3cce55b71a8a3f3c418c329a66e5f714431 | 0xdef1c0ded9bec7f1a1670819833240f027b25eff | 0xc5b49abf8b164472be9486767af6b1a5586b5609 |
transactionIndex | 0xea | 0x86 | 0x28 |
value | 0x0 | 0x0 | 0x0 |
type | 0x2 | 0x0 | 0x0 |
accessList | [] | NaN | NaN |
chainId | 0x1 | NaN | NaN |
v | 0x1 | 0x25 | 0x26 |
r | 0xc903a46590ec28f688f32855702ce4ba93dc41abfea7... | 0x18faa03917f1f7933e61e1d18468ff06c661e315d866... | 0x94567659a313430951a53d93a218259e6f556964e012... |
s | 0x8112d963da3427e774f159e86dba2284af135f35fbcd... | 0x58d5808e701496ee978b9c5801f49e76199dfda12a44... | 0x5f20b4c0fe585feb938907cdcc1ef7faf6dad65b0f73... |
get_eth_transaction_by_block_index
Returns information about a transaction by block number and transaction index position
[29]:
txn_info = es.get_eth_transaction_by_block_index(blocks[0], index)
time.sleep(1)
txn_info
[29]:
transaction_info | |
---|---|
blockHash | 0x39d5dd282cb927a8a4d48067753d65d4e94cf91f161d... |
blockNumber | 0xc93e27 |
from | 0xa06c0c2b2ce1918a148e5c6ea9f32a374ef44ba8 |
gas | 0x5208 |
gasPrice | 0x22ecb25c00 |
hash | 0xc340f61db160cba7c5052b8e48672848d204fe8e3d1f... |
input | 0x |
nonce | 0x4f7 |
to | 0x398226801b7f0fd8c3c846b7d99ccdc4298dc2f6 |
transactionIndex | 0x0 |
value | 0x6f05b59d3b20000 |
type | 0x0 |
v | 0x26 |
r | 0xda78de4032212d9b2f660e5bc7922e345d7f413768d3... |
s | 0x7cc3f475382011d09f74c733e5845ee74716e7a7c0ea... |
get_eth_account_transaction_count
Returns the number of transactions performed by an address
[30]:
transaction_count = es.get_eth_account_transaction_count(accounts)
time.sleep(1)
transaction_count
[30]:
transaction_count | |
---|---|
0xBa19BdFF99065d9ABF3dF8CE942390B97fd71B12 | 213 |
0x503e4bfe8299D486701BC7bc7F2Ea94f50035daC | 70 |
get_eth_transaction_receipt
Returns the receipt of a transaction by transaction hash
[31]:
receipts = es.get_eth_transaction_receipt(txns)
time.sleep(1)
receipts
[31]:
0x29f2df8ce6a0e2a93bddacdfcceb9fd847630dcd1d25ad1ec3402cc449fa1eb6 | ... | 0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787e341eea230614e49ff61 | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
blockHash | blockNumber | contractAddress | cumulativeGasUsed | effectiveGasPrice | from | gasUsed | logs | logsBloom | status | ... | effectiveGasPrice | from | gasUsed | logs | logsBloom | status | to | transactionHash | transactionIndex | type | |
0 | 0xe3bfc6bb26456cc452d15fe2de6ed3931e9a0fa289dd... | 0xd09183 | None | 0x137614c | 0x1b348f74bf | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x1e384 | {'address': '0xee2ebccb7cdb34a8a822b589f9e8427... | 0x00000000000000000000000000000000040000000000... | 0x1 | ... | 0x3286353a00 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x495ba | {'address': '0xdcd90c7f6324cfa40d7169ef80b1203... | 0x00000000000000000000000000000002000000000000... | 0x1 | 0xc5b49abf8b164472be9486767af6b1a5586b5609 | 0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787... | 0x28 | 0x0 |
1 | 0xe3bfc6bb26456cc452d15fe2de6ed3931e9a0fa289dd... | 0xd09183 | None | 0x137614c | 0x1b348f74bf | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x1e384 | {'address': '0xd569d3cce55b71a8a3f3c418c329a66... | 0x00000000000000000000000000000000040000000000... | 0x1 | ... | 0x3286353a00 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x495ba | {'address': '0xdcd90c7f6324cfa40d7169ef80b1203... | 0x00000000000000000000000000000002000000000000... | 0x1 | 0xc5b49abf8b164472be9486767af6b1a5586b5609 | 0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787... | 0x28 | 0x0 |
2 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | 0x3286353a00 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x495ba | {'address': '0xdcd90c7f6324cfa40d7169ef80b1203... | 0x00000000000000000000000000000002000000000000... | 0x1 | 0xc5b49abf8b164472be9486767af6b1a5586b5609 | 0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787... | 0x28 | 0x0 |
3 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | 0x3286353a00 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x495ba | {'address': '0x06325440d014e39736583c165c2963b... | 0x00000000000000000000000000000002000000000000... | 0x1 | 0xc5b49abf8b164472be9486767af6b1a5586b5609 | 0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787... | 0x28 | 0x0 |
4 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | 0x3286353a00 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x495ba | {'address': '0x06325440d014e39736583c165c2963b... | 0x00000000000000000000000000000002000000000000... | 0x1 | 0xc5b49abf8b164472be9486767af6b1a5586b5609 | 0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787... | 0x28 | 0x0 |
5 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | 0x3286353a00 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x495ba | {'address': '0x06325440d014e39736583c165c2963b... | 0x00000000000000000000000000000002000000000000... | 0x1 | 0xc5b49abf8b164472be9486767af6b1a5586b5609 | 0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787... | 0x28 | 0x0 |
6 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | 0x3286353a00 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x495ba | {'address': '0x06325440d014e39736583c165c2963b... | 0x00000000000000000000000000000002000000000000... | 0x1 | 0xc5b49abf8b164472be9486767af6b1a5586b5609 | 0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787... | 0x28 | 0x0 |
7 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | 0x3286353a00 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x495ba | {'address': '0x06325440d014e39736583c165c2963b... | 0x00000000000000000000000000000002000000000000... | 0x1 | 0xc5b49abf8b164472be9486767af6b1a5586b5609 | 0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787... | 0x28 | 0x0 |
8 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | 0x3286353a00 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x495ba | {'address': '0xdc24316b9ae028f1497c275eb9192a3... | 0x00000000000000000000000000000002000000000000... | 0x1 | 0xc5b49abf8b164472be9486767af6b1a5586b5609 | 0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787... | 0x28 | 0x0 |
9 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | 0x3286353a00 | 0xba19bdff99065d9abf3df8ce942390b97fd71b12 | 0x495ba | {'address': '0x4ae9e68bd76eba868be20376eea343e... | 0x00000000000000000000000000000002000000000000... | 0x1 | 0xc5b49abf8b164472be9486767af6b1a5586b5609 | 0x1815a03dd8a1ce7da5a7a4304fa5fae1a8f4f3c20787... | 0x28 | 0x0 |
10 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
11 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
12 rows × 42 columns
get_eth_gas_price
Returns the current price per gas in wei
[32]:
gas_price = es.get_eth_gas_price()
time.sleep(1)
gas_price
[32]:
63488530079
Tokens
Functions to return information about tokens
[33]:
#pickle, xSushi
tokens = ['0x429881672B9AE42b8EbA0E26cD9C73711b891Ca5', '0x8798249c2E607446EfB7Ad49eC89dD1865Ff4272']
# One account w/ the above tokens, one account w/out the above tokens
accounts = ['0xBa19BdFF99065d9ABF3dF8CE942390B97fd71B12', '0x503e4bfe8299D486701BC7bc7F2Ea94f50035daC']
get_token_total_supply
Returns the current amount of an ERC-20 token(s) in circulation
NOTE: supply is not adjusted for decimals of token(s)
[34]:
total_supply = es.get_token_total_supply(tokens)
time.sleep(1)
total_supply
[34]:
supply | |
---|---|
0x429881672B9AE42b8EbA0E26cD9C73711b891Ca5 | 1848976414779307269364005 |
0x8798249c2E607446EfB7Ad49eC89dD1865Ff4272 | 53738914806120315201730649 |
get_token_account_balance
Returns the current balance of an ERC-20 token(s) of an address(es).
NOTE: balance is not adjusted for decimals of token(s)
[35]:
account_balance = es.get_token_account_balance(tokens, accounts)
time.sleep(1)
account_balance
[35]:
0xBa19BdFF99065d9ABF3dF8CE942390B97fd71B12 | 0x503e4bfe8299D486701BC7bc7F2Ea94f50035daC | |
---|---|---|
0x429881672B9AE42b8EbA0E26cD9C73711b891Ca5 | 3032297953281047468 | 0 |
0x8798249c2E607446EfB7Ad49eC89dD1865Ff4272 | 1898359331077965312 | 0 |
Gas Tracker
Functions to return information about gas
[36]:
gas_price_wei=2000000000
get_est_confirmation
Returns the estimated time, in seconds, for a transaction to be confirmed on the blockchain gas price in wei
[37]:
est_confirmation = es.get_est_confirmation(gas_price_wei)
time.sleep(1)
est_confirmation
[37]:
'3615'
get_gas_oracle
Returns the current Safe, Proposed and Fast gas prices
[38]:
gas_oracle = es.get_gas_oracle()
time.sleep(1)
gas_oracle
[38]:
gas_oracle | |
---|---|
LastBlock | 13761570 |
SafeGasPrice | 71 |
ProposeGasPrice | 71 |
FastGasPrice | 71 |
suggestBaseFee | 70.125539676 |
gasUsedRatio | 0.673301292438634,0.390934289089044,0.16035321... |
Stats
Functions to return statistics supported by Etherscan
[39]:
start_date='2021-01-01'
end_date='2021-01-05'
get_eth_total_supply
Returns the current amount of Ether in circulation
[40]:
total_eth_supply = es.get_total_eth_supply()
time.sleep(1)
total_eth_supply
[40]:
'118647896311500000000000000'
get_eth2_total_supply
Returns the current amount of Ether in circulation, ETH2 Staking rewards and EIP1559 burnt fees statistics
[41]:
total_eth2_supply = es.get_total_eth2_supply()
time.sleep(1)
total_eth2_supply
[41]:
eth2_supply | |
---|---|
EthSupply | 118647896311500000000000000 |
Eth2Staking | 352534008030225000000000 |
BurntFees | 1133291322548617997182297 |
get_last_eth_price
Returns the latest price of 1 ETH in BTC & USD
[42]:
last_eth_price = es.get_last_eth_price()
time.sleep(1)
last_eth_price
[42]:
eth_price | |
---|---|
btc | 0.08512 |
usd | 4309.29 |
get_nodes_size
Returns the size of the Ethereum blockchain, in bytes, over a date range
[43]:
nodes_size = es.get_nodes_size(start_date=start_date, end_date=end_date)
time.sleep(1)
nodes_size
[43]:
blockNumber | chainTimeStamp | chainSize | clientType | syncMode | |
---|---|---|---|---|---|
0 | 11565064 | 2021-01-01 | 6451682486621 | Geth | Archive |
1 | 11571611 | 2021-01-02 | 6458928956583 | Geth | Archive |
2 | 11578201 | 2021-01-03 | 6469047014437 | Geth | Archive |
3 | 11584682 | 2021-01-04 | 6476583029570 | Geth | Archive |
4 | 11591201 | 2021-01-05 | 6486626025242 | Geth | Archive |
get_total_nodes_count
Returns the total number of discoverable Ethereum nodes
[44]:
total_nodes_count = es.get_total_nodes_count()
time.sleep(1)
total_nodes_count
[44]:
'2543'
[ ]: