No project description provided
Project description
hypersync-client-python
Python package for Envio's HyperSync client written in Rust
feedback and issues are appreciated :)
Can find more examples in examples/
Ex: run examples/all-erc20.py
$ python3 examples/all-erc20.py
Example usage
import hypersync
import asyncio
async def main():
# Create hypersync client using the mainnet hypersync endpoint
client = hypersync.hypersync_client(
"https://eth.hypersync.xyz",
)
height = await client.get_height()
print("Height:", height)
# The address we want to get all ERC20 transfers and transactions for
addr = "1e037f97d730Cc881e77F01E409D828b0bb14de0"
# The query to run
query = {
# start from block 0 and go to the end of the chain (we don't specify a toBlock).
"from_block": 0,
# The logs we want. We will also automatically get transactions and blocks relating to these logs (the query implicitly joins them)
"logs": [
{
"topics": [
# We want ERC20 transfers
["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"],
[],
# We want the transfers that go to this address.
# appending zeroes because topic is 32 bytes but address is 20 bytes
["0x000000000000000000000000" + addr],
],
},
{
"topics": [
# We want ERC20 transfers
["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"],
# We want the transfers that go to this address.
# appending zeroes because topic is 32 bytes but address is 20 bytes
["0x000000000000000000000000" + addr],
[],
],
},
],
"transactions": [
# We want all the transactions that come from this address
{"from": ["0x" + addr]},
# We want all the transactions that went to this address
{"to": ["0x" + addr]},
],
# Select the fields we are interested in
"field_selection": {
"block": ["number", "timestamp", "hash"],
"log": [
"block_number",
"log_index",
"transaction_index",
"data",
"address",
"topic0",
"topic1",
"topic2",
"topic3",
],
"transaction": [
"block_number",
"transaction_index",
"hash",
"from",
"to",
"value",
"input",
],
},
}
print("query: ", query)
# run the query once
res = await client.send_req(query)
print("res: ", res)
# read json abi file for erc20
with open('./erc20.abi.json', 'r') as json_file:
abi = json_file.read()
# every log we get should be decodable by this abi but we don't know
# the specific contract addresses since we are indexing all erc20 transfers.
abis = {}
for log in res.data.logs:
abis[log.address] = abi
# create a decoder based on our abi file
decoder = hypersync.Decoder(abis)
# decode the logs using the decoder
decoded_logs = decoder.decode_logs_sync(res.data.logs)
print("decoded logs:")
for decoded_log in decoded_logs:
print(decoded_log.indexed)
print(decoded_log.body)
# Create a parquet folder by running this query and writing the contents to disk
await client.create_parquet_folder(query, "data")
print("finished writing parquet folder")
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hypersync-0.3.0.tar.gz
(42.6 kB
view hashes)
Built Distributions
Close
Hashes for hypersync-0.3.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 821d0e25b658038edcbc670b64dba2630415b87d4568b8e86c2f82e4aca7221a |
|
MD5 | 236708ddce2f4cf8ea2ce8725ce6f3eb |
|
BLAKE2b-256 | 6384db9dcc0771f6c37f9bc70ef6d8e63f868fe58c6afbe8dff59e531c4bff52 |
Close
Hashes for hypersync-0.3.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 877e8fa2e93538cf15ef4cc08838229561aa823b2148f245225677b70b815c98 |
|
MD5 | 51d5c0cce5b35d0d6fee79da808eaf3c |
|
BLAKE2b-256 | 4181751e6bb47377ee4e161619eaea06e723ff24069b654f8c9f1a6de113448c |
Close
Hashes for hypersync-0.3.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fe5bd26df40bc591b3eeeeee278b707b424a6ab474a3a71092d35ce32503717 |
|
MD5 | b5cad989db17c4f2ffd353a344eddf7a |
|
BLAKE2b-256 | bb9e7e27710b3843507f888f81188b9f8fe5e60c69e6a57251dd375413995455 |
Close
Hashes for hypersync-0.3.0-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39495c6e7d2f7afe68842a49695ca3c8559043257fb2d8f3c33164b92362f52e |
|
MD5 | e6c6d8a0ecd68f41fc90311d7843a550 |
|
BLAKE2b-256 | 2d92889ca53687098bc5a4f72d649e36ece6018c10ed5dca683376463003dc1c |
Close
Hashes for hypersync-0.3.0-cp312-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76c55c30f2c8446d10f7794cdab26e806aeec46cc5bcd7afdf54f91f97f49621 |
|
MD5 | d37a8f83c3787e0fef42bcc4794a4025 |
|
BLAKE2b-256 | 0c46c0bd5b26ba76f7f886e8dbbf13f61f2c597823b2a7f17b81dac780fadcc0 |
Close
Hashes for hypersync-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc6ff52e103c8c2123fbc959ead1f5ae6fec7e3753990d52cba67701a6643e3b |
|
MD5 | b5e1cd81f40977d4b9631b57cca25c9c |
|
BLAKE2b-256 | 6e4759c3b97481734f38be9431b9aa815e352730fef536281f333055db861b83 |
Close
Hashes for hypersync-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb36f1754196d3787a112b1d55a1c2423ddfff2171e1e5f65eadd89637fef284 |
|
MD5 | 9c96c7d0d1e0ea2ad7c653f4779619f5 |
|
BLAKE2b-256 | 3af61259c9e7e1299eb72b6a78d651ca7b3f7a4fdb487c77e22b50ea99a30894 |
Close
Hashes for hypersync-0.3.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f689cd834d80053044f253ce173bdf1c04934bb1ca4072c74f252bcf8ef562df |
|
MD5 | 087bf9a13d1a51e3f62a9671da58f188 |
|
BLAKE2b-256 | 94fa4b30bf35e5051eca4c5b247174611496fd7722671fc4d1d5c9dcdb36caec |
Close
Hashes for hypersync-0.3.0-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d98210f52fab441215a153111a6a8f38eb76b92f37e9f70937a547a70de13a6 |
|
MD5 | 999853fc6545b77688cb0b25fcae109d |
|
BLAKE2b-256 | 5b5a8d797f595f2f891c0fc45b9201e3be67777236bdc46801435cf5d5dfbe9f |
Close
Hashes for hypersync-0.3.0-cp311-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd4fe903039b58736508a5e4d31e3345b941df72cff3bc7810732f62d35fdbe0 |
|
MD5 | 88741d8ddcf05b2bfa427cfe86f48125 |
|
BLAKE2b-256 | 33141825db49889bc19a5a2557df02b36c577be8cd91bbfa720c5fe4c9c4bce7 |
Close
Hashes for hypersync-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b47be3971d443b02c91ea46a40f6c0278574f3e60f3dc101f1734bb36ce6568 |
|
MD5 | 509ed7521a83cc356fd2fc1f42f3cd06 |
|
BLAKE2b-256 | 3adb7206e4d9fcd31b4ad3ecb9ae92acdb4a3abf764c5cbe506c6c67042b8ee8 |
Close
Hashes for hypersync-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7aef742f9bb2f03970b810188169371705822acb2ad881f559bdb19e5afa24d3 |
|
MD5 | 15e4c6161aaa55ef5d14c198fd1018a0 |
|
BLAKE2b-256 | 604f179f0758a1274079f81fa719ba681a69234272c487c9e378871e536e44d4 |
Close
Hashes for hypersync-0.3.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9c1fd21eead415dc12dcd7b905925f5ade5aea091b2e7c899b2b7401d84f29c |
|
MD5 | ca42ec43d8e4abead1b41ec9c2fe942c |
|
BLAKE2b-256 | ce7e3d6354f2da4dffb3e193d6885f10f3e2a46c7e789442f877739c07a7159f |
Close
Hashes for hypersync-0.3.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24ca72cbc3be20f326abdde74ea04eb74f5ce5de2bea9a003876f7f8370765a9 |
|
MD5 | 2c6b68b64b768bcb652131f85b291b19 |
|
BLAKE2b-256 | a9bb0f336c8b91d4d33646ccba17f1a1d35eaab48ba8e6b1ea8fd53056f287b7 |
Close
Hashes for hypersync-0.3.0-cp310-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e53c08cf36f74ee677c9de9ce08cba2a89dbf65ab0c877e26c6a86df5dc7ab2c |
|
MD5 | ea45642cc07998abc89cb5fbc80df73b |
|
BLAKE2b-256 | 2539ff146436bbd9d5fd0f1623062c144b58ded8df45c1e2e9e50faad4e46612 |
Close
Hashes for hypersync-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6d36025b5e68e44dc8277234fa08997613e4ddcf59c481fce22307436f56272 |
|
MD5 | 0646ca41be7820ab4337b5d9462a5a61 |
|
BLAKE2b-256 | 3654bed1dece069b6c88670d32ad8916df8fa6e38baca4173b01387e15d64e14 |
Close
Hashes for hypersync-0.3.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50a3b5395bf5c13b5f2859a442815afd27dd81b2a98b487ff6d2ff9aa10b24c8 |
|
MD5 | 3f681e6952ae6eb762ef35c73f8d2ab2 |
|
BLAKE2b-256 | 59b3e39b58b032741ca0a33021bc7067c64d55d7ab53f9fc6e5f5b298f3b052d |
Close
Hashes for hypersync-0.3.0-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51be2db06a7d8db796efd87a7728a9f2471c25883b37e039d07a3de50ea2d0a5 |
|
MD5 | 4704f3c427138d56438836033bad8770 |
|
BLAKE2b-256 | a16dfc4419c4387b8364bfdc722d7cf741073ab6ff2810f71c962e02a515098a |
Close
Hashes for hypersync-0.3.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8790e6d275e474910f75822cf1b988a5327fdd0551e8b6de31f210dd6d9b9cd2 |
|
MD5 | 9ee19c4b9d28331242e8e67fd6353053 |
|
BLAKE2b-256 | a334089737c6de4e4227d16d129478cc762a3e468d3ba73dc55c61197e1b3a4b |
Close
Hashes for hypersync-0.3.0-cp39-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ced30169d43d06480b4dbb9712bc7df66ece6e6026bf3e375ede975f8cf7c1d0 |
|
MD5 | 0eca6f13f7d0ad65970c991fe298b1e0 |
|
BLAKE2b-256 | f41eb17f277c8d831be597f381a759ae76eee214ca42ef82a9347b20bab7e15e |
Close
Hashes for hypersync-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82d6ecba4d9946184fba707765d599b9ff7c1ae99efc163b5252c7682d777ecb |
|
MD5 | 346f0497cb3da0d2b62bfb524e9d5229 |
|
BLAKE2b-256 | 7f1e8a5abf361f58b40576171199a195317cfe3d585c166d033538ed8b5f4a1a |
Close
Hashes for hypersync-0.3.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d93cb8eab5fb4afb59b179ae8f9d9bec8a269e09b1ecbdf5685d9d9872d9441 |
|
MD5 | 968db0d1b8448452c6b23cd23f8833f2 |
|
BLAKE2b-256 | 21de07d92a64df927cd55b8add54696e8b2a3c281735cb665770e7434289801e |
Close
Hashes for hypersync-0.3.0-cp38-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf1615e0d5753911b41e66fe180635a9cb560ae357067b41e26f4a46a86474f9 |
|
MD5 | c4f2ddd24f6faaf964ce50c28984bb46 |
|
BLAKE2b-256 | b43c4c815d17ef7126acf2e7df1528a23084fa5e1c608791cf28693699d12042 |
Close
Hashes for hypersync-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dde7137490ca90d2779c17071a1a46781d82c607d4713ca3e2db655c128178a |
|
MD5 | 5ba5f0d9aa98dec649ab19b453257b3a |
|
BLAKE2b-256 | 95074ec69e7ff8c7785f4ff1f3e21e8b7564d0ca06191d3eabe08b171b19d3b6 |