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.2.0.tar.gz
(40.4 kB
view hashes)
Built Distributions
Close
Hashes for hypersync-0.2.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d02359100c42f26a56490096cf194d39a3e75385ec9b76f4b35d3085ea14d993 |
|
MD5 | b1c6c5f33a93e7b5218f372346d1de45 |
|
BLAKE2b-256 | 6dfef0b0831973e6e4263d5888ddf1184088cc363b3a8176ac902324555aeb70 |
Close
Hashes for hypersync-0.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36f4d71596a5c986d4f5e8d9d6b213fd8baca19d476ecfada30cafdf11514af1 |
|
MD5 | 1a48a70e37812a7a38337c09cddb2946 |
|
BLAKE2b-256 | bf415f34a85fe3da21bb55dea2246074607bb66cce2d848a9f0715bea306768c |
Close
Hashes for hypersync-0.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c88816738f860f0c8b5c688bc7845d0cfd5b032584ae3d93c934683ae21ce7c5 |
|
MD5 | f190a1b44e27069a6dffec995756e13e |
|
BLAKE2b-256 | b603c0672869d8ac7d8b5223f98c421f854973915735bdcf9b2374e062cb63b4 |
Close
Hashes for hypersync-0.2.0-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee56f2eb09c98efe3847f4036ece865f9c9ccb60a7877963e21031387e71e9a5 |
|
MD5 | e08e3dbab2991f6dfaa57eada14c2744 |
|
BLAKE2b-256 | e15cc163c6142012ddacc0806000a1a69d070b930f1e505dadae8987df046205 |
Close
Hashes for hypersync-0.2.0-cp312-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6b13a8c90d07842440b05228caa357646d96c42e9d81bb883c7c560202847a7 |
|
MD5 | 06a96f763338cc4fd41d986c50aea199 |
|
BLAKE2b-256 | 145c9f4ac246931c100acfaac71a64f8f02af30a13a3af354de27096aeaf9da7 |
Close
Hashes for hypersync-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8de794b5289adec13f8a7a38e3e41a5edb9686bf5b253027c57c128417a77f77 |
|
MD5 | 238b224382541488327b5da6bcd18517 |
|
BLAKE2b-256 | 7ba06aa41c27928cdb762e932497c6a865af217480f17c15aa3381feec1ce002 |
Close
Hashes for hypersync-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8224a1cd4b6f3349bf8b1ab8e76f30bf8d07d85f2ea4a678a6773141d3cb856e |
|
MD5 | 46851f067ab4478049cb6008e66d7f4c |
|
BLAKE2b-256 | 16f105465d09be91c8ce09cde9996fd2be254b31257b62a2eb6aeb19fcfd2cac |
Close
Hashes for hypersync-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b70f3ef3556cc0ec0a405b92dc0f6c5da4a8ba73c4de91f9aaaaec608095b6f5 |
|
MD5 | 7ff3c026e621c0c702bc18efc624a1b7 |
|
BLAKE2b-256 | 8276d6618cb5aee85f7f467b9ae9637a7c616ffbf6cd6d840171a32ea84c1ff5 |
Close
Hashes for hypersync-0.2.0-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 396c73c52e745a5caa2501c20f2e505fdaa7f44b290fb47c93c6c2fdcd9db4bc |
|
MD5 | 88c40a4296a32b5ae5090d7016044a4c |
|
BLAKE2b-256 | c7cbf3fcffb6ee77c5f2aabbd6f2add1a13a58dc45ae5d595ad74ba74560f9b7 |
Close
Hashes for hypersync-0.2.0-cp311-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53c74bbd12d03248b34ea78bacdc6e096d4d475d84aafd1f1235be07f8939839 |
|
MD5 | f74fcd1865e14659ff287ab0579d2e74 |
|
BLAKE2b-256 | 1049d8773a38d7f356c747a3919bc69be9d51061778aa18efe33ef80f8e5e65f |
Close
Hashes for hypersync-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 550cc859652d657c21d1f69ab2915106525160e7099b8c47476355eb172351a6 |
|
MD5 | b17afe36d279415925ac046aebab0488 |
|
BLAKE2b-256 | f0aa126627adb6673a4242d96678f2c7bb3ed16ee673211070ff7be97f7f95fa |
Close
Hashes for hypersync-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 709bdb109f10d5d232b4861b277b2d6372d44a113e46bbaf97c3c73b6fb6ba32 |
|
MD5 | cfd167d0eec8bfd7706ef41b5fcf4225 |
|
BLAKE2b-256 | 151a142255bc0a4ac2ee2138d47ded286304eadaefd34b587eae33cb223f2ed7 |
Close
Hashes for hypersync-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49b425ee785085930614edded3cf9c58e0dc51d44c1cb74e62e0b7f67227dc09 |
|
MD5 | c21d44965b4e0929e1456c704fcbd35b |
|
BLAKE2b-256 | 0360f760fa49f49d340b4a32c1f02ee41e3715d24f6d1ac42f24aaca2e6b8e1f |
Close
Hashes for hypersync-0.2.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 481d7c0bc3157e62bc6b0e3b8c628628e9d7a50c62997e08e8fb66ac21ea6b15 |
|
MD5 | c43c10d8bed52ebc2fa30a0b814c4b2b |
|
BLAKE2b-256 | b1d9de3dea8f00902beba448dc5a2894ba58c974fd77bbd6cc22335026d9267e |
Close
Hashes for hypersync-0.2.0-cp310-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e442c9f845e802bda116b6a48db38926293a558e5d920e51706a97620fcccb8 |
|
MD5 | 8a24af99bbacaa106bd4f8a27c8ecf89 |
|
BLAKE2b-256 | 454a99a6c2d9b24fb78a650f8b6f636d231cdf0a53008a7c13fd240de3330951 |
Close
Hashes for hypersync-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45a37dd7571bb344e62e8de2308461194b0ca1b55f209e3f466eb89afcaaee0a |
|
MD5 | d112566ec738190b5bbe3ac2688d91e7 |
|
BLAKE2b-256 | 7c66d3284722387f4ecc35314676ffce669f17fe017c787d7cf651109ab6ed06 |
Close
Hashes for hypersync-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ceb8302362c3348f8aa84bfb47cf855caff7c9fb32999670b7b6df57c1e7922 |
|
MD5 | a68758cd7fc25dbdfd8935c3b7d97579 |
|
BLAKE2b-256 | 87b31ddc3048dfa36d15b7132c4a3b9b9e2cfe4f8a46f850a495d88809961022 |
Close
Hashes for hypersync-0.2.0-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc08d41c0fe81af341083613533f58775b947727599efcc2f9f39cb05a1fea74 |
|
MD5 | 7bfdfdb5031db704f63c0bd856435503 |
|
BLAKE2b-256 | 7f92906827ad730e61cd0585cda90f38d43e3dfb054a3ce09a77f16834a1ac0f |
Close
Hashes for hypersync-0.2.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b0cd58ae454751d29168a0d0ffc9e40aafa123e158ba60b654c022f360336a0 |
|
MD5 | 61711892915ca87e5c6838b14997fc35 |
|
BLAKE2b-256 | 00ecec447f45e43bb5b15f91295d3a060d78cc9e442717253c22e9c5d71c2cbe |
Close
Hashes for hypersync-0.2.0-cp39-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c88ad25b9cc8e6ddfb4402077416b56f4c37bb370c5d4244b8a31e1892071ecc |
|
MD5 | 590a1b49d351ac2f2436b166e55ae254 |
|
BLAKE2b-256 | aa3bc80749023a7a207da4343cc0374dc6bfd3c9e30c16a12f16be5514ebc50a |
Close
Hashes for hypersync-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cf1dbe0db6ef5704625fa383dd77037175e462f44074a56087fb5d47b218848 |
|
MD5 | 16acd7a5f320c683daf435b425a5008c |
|
BLAKE2b-256 | decb566def53e370b0f8a7fdcd66c45af8a886a94ce3c32bdb71c66dd6ec03bb |
Close
Hashes for hypersync-0.2.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a6b10cec85547d4f603f3c67ecb0ed97fd695110ced820466ca973a76d0c533 |
|
MD5 | c57fac35e73657331ac7a5ca1f081103 |
|
BLAKE2b-256 | 461f0213b9fd291f0d779634ca433756ef653e7fdd1107f566d622d556b32c3c |
Close
Hashes for hypersync-0.2.0-cp38-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f920383c7f4e6344d799fb4556bd90b0d5c40769d6f4b28731922b6c8dbf4724 |
|
MD5 | f0561f3db85afa9f3dc16cee4619178b |
|
BLAKE2b-256 | edb8b5aa6f2d0abb10e6b9a13cbc89f914db167fcb6c47f7bd956282416fb1b3 |
Close
Hashes for hypersync-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14fb1151b4722457e20d9476049f5020d774ef4e3a528b3f721875345fe42df2 |
|
MD5 | 52e81876cce54f4ed372370bfef5578f |
|
BLAKE2b-256 | 7eaa6cfd6018e040bd9861b0830b59fc0cc7d6f8a93d8155a3fcb6c5d37e5f2a |