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.5.2.tar.gz
(44.3 kB
view hashes)
Built Distributions
Close
Hashes for hypersync-0.5.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a91edcb8fe85fc2ca0c2374bfc986b5bd13d91565e9c6d7aad9142a29cac3592 |
|
MD5 | 9b99d54ebc0bb0d071562fb0e1daa5fc |
|
BLAKE2b-256 | bd4158ffeaf0ff52f4e23492969d28ae919a34b0d61d25e334d692b7c90ebc76 |
Close
Hashes for hypersync-0.5.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ea3b3d8edcb47b47ce6c1f86364684e4cbb06942912b315ebcb6f5e0e14488d |
|
MD5 | 56f529c1b517cfd94cf2b9f6b09cb644 |
|
BLAKE2b-256 | a2079c71a0392295e8623c9fcbfd7c08d045a387ddf50b40879355da7f509547 |
Close
Hashes for hypersync-0.5.2-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d774a560354e5b768059a70aed082991ec8290b03d397d634051b3376aa986e |
|
MD5 | d51dc82a4c8a5b5e91506ddba6e813bf |
|
BLAKE2b-256 | e8357f8a95e8c7034125a23710bd4fe694829bf2bf0034174b5f5ea261ee7778 |
Close
Hashes for hypersync-0.5.2-cp312-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26bff6eb4b248b24f870beb6debc0cb3c9b63dd82b460138d8c6281eaee02e38 |
|
MD5 | edba7982b108624034ff2c89a8d5648f |
|
BLAKE2b-256 | 2e277b1aae60124e08809b0febd4c30d40f82f7d427be391578e2c34e3c3b32d |
Close
Hashes for hypersync-0.5.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47471db4a4375ba93d1e723497eb9916cb0c6a35413aa51a6e67fcf6203add10 |
|
MD5 | e5dc384ca5e332c9b57f588b81de101c |
|
BLAKE2b-256 | c8ae99d540479da5fa9834a60231cc68bc71a3b0e6a1be67198429347f4b7ab4 |
Close
Hashes for hypersync-0.5.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | acfcdbe859b660515d3f085d7d5ad9cfe9e966d7946dee7f9c57f253f4920157 |
|
MD5 | 06c207e325a82b8b7cee5c4252341f9f |
|
BLAKE2b-256 | ba137bff3a8543e9f411f5ef66338775be61fee4901503311c9a74b89f39933f |
Close
Hashes for hypersync-0.5.2-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0ba93f2cb906635154b7c83947da1ff19c394340d031cf442f9aa595e2d0547 |
|
MD5 | 8ded35e4eb2bf08d3ca874a3d74844f8 |
|
BLAKE2b-256 | 38dcdcd184172beb5629c5727a48e0594a1dc5ded120b2f08ad7da378bf4bcff |
Close
Hashes for hypersync-0.5.2-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eca49cd8e9f1153fcab41e0eda117b7862b63569d587e8f1a9667e4839b73f52 |
|
MD5 | 0e4011715286850fa72d10403519f65b |
|
BLAKE2b-256 | 493ad14c001ee35782299b04a863d18da714f79fb41aaa8f1b912c77eb71ce12 |
Close
Hashes for hypersync-0.5.2-cp311-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc7e03ddd34fb64258fe69fc420bb00639577a077b19d5f4a720818f75ac1809 |
|
MD5 | 9bfe611b5e1731647c61ebc21b78e68c |
|
BLAKE2b-256 | 47aa6b7bf2cba0aaf4e8d890cb7bac7a4297c6ca760a64cb86309bc684cd14d6 |
Close
Hashes for hypersync-0.5.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6728ec1afbfe99cd4620686b2d896d8d2aacd57ad53e31bcbf755ca974d3c83 |
|
MD5 | 632b97f492bfa02829d07905a307a8d8 |
|
BLAKE2b-256 | 9eb451cbe1fc1c2602ccca58ec294545b85f905fb97465146beff2f4679432d0 |
Close
Hashes for hypersync-0.5.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 543dc4be21609e3e60eac6545003263ddac5195ca6d2f310c0c2328f38865b3e |
|
MD5 | 9dd696ee5009e9ba7c645abd93d22947 |
|
BLAKE2b-256 | d7a97edac899855a29eaa6d83f6f6570d79bb6197884dd783c1d33dd02b70ec9 |
Close
Hashes for hypersync-0.5.2-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06054fc61fd9547952b578cb3e0f0246908f87b4652506ac6a148fc55d7c1fbb |
|
MD5 | 139946fd754a367446648e6aa81143e0 |
|
BLAKE2b-256 | d2f921e850c096268fd8ab1f6f1b93d8e0a354853eb9f67e4aab6e7775467b15 |
Close
Hashes for hypersync-0.5.2-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28f9c325881b4770bd69f5584aa04b9579c228f6446297064a217493b67bcad3 |
|
MD5 | 14cebe4871e66c3d0ec528998be78014 |
|
BLAKE2b-256 | f3ad788de599aa0ec5f0b146c3f90200a1b3da31000ebfb3944958def3040e2d |
Close
Hashes for hypersync-0.5.2-cp310-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b1a679d7fa9b470fbd63831c39eb0f00d31e69297f2ac55ff404e30b65369b7 |
|
MD5 | b51d620513cb584c2d06b623744419fe |
|
BLAKE2b-256 | 51aef444c58db90853b944e0cb13b55b30c45f2e8e1d00bff4f1cfd72c0756e5 |
Close
Hashes for hypersync-0.5.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7eaad666b1bf7891fcd585dea3a0b5209fcda4ddf1e26f15d90da47369acfea8 |
|
MD5 | 6fa3ef1a17ad4ab4b59f5186fc494c4f |
|
BLAKE2b-256 | 7748a93905b270f4830899733bed40f3d3763912edf3ecaa02b67c81b76c146d |
Close
Hashes for hypersync-0.5.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a7b9a1d982899750d339adb3fcb6528d4eb0470e1c151b152df216116f58b5b |
|
MD5 | 8558fbd042b06dc1bb9e1f9918381ed3 |
|
BLAKE2b-256 | 930fb8ac6ae11a9192b2c6466047f2bccf90cbc7e9e27ac86b07fbdbb61d9d91 |
Close
Hashes for hypersync-0.5.2-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33f61bffe0d81bd2cf43b07d3fdc9b40f64ac5851981e2a278c4520fff9364af |
|
MD5 | 6a617013b644c1fba7ecf88982d209ac |
|
BLAKE2b-256 | e8f2b633c380cfde24186250bae55c88653dc76c18fe0f72de9c0cad146b618d |
Close
Hashes for hypersync-0.5.2-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73006209fb18341f0d4de27c32939ff9b8d3c0bede15fe619f83b95eeb5b64ce |
|
MD5 | 02b1d57d7c1f4b06e5a5608011edd2b7 |
|
BLAKE2b-256 | c78ec491677121809630726b955690ad9c5637d1968c4a8c26a06d1a96d8abfb |
Close
Hashes for hypersync-0.5.2-cp39-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 731097cf94004453dc448fff590ca19b9e381482b66f71d2a9f4e73fbb65fb0b |
|
MD5 | f055f5a1c8fab4d7632eddaa702a2969 |
|
BLAKE2b-256 | 2c2a8b4c7531ef68c965db9600238133a7922594e3eb0c7932759f8c568c747a |
Close
Hashes for hypersync-0.5.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed1d14d6e81d6063eb200db519479b3ae78d4c5f2f55b42f2bc55ca83753d4b3 |
|
MD5 | d5054e30ab55a8afd0cc0b3e684fac94 |
|
BLAKE2b-256 | 8f82bd8777615e752ed0c57ea1d947fe9cfe8c099696fa7e28b8805ad5f4c196 |