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.4.0.tar.gz
(44.3 kB
view hashes)
Built Distributions
Close
Hashes for hypersync-0.4.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f757f6cf68bbaacb0d71bbd4eaba2c2d223d2f8423f9c5377ffcf515e95e79ba |
|
MD5 | ff6a632fbd3b61e82d7f5ceedb517f44 |
|
BLAKE2b-256 | 7b98530f3df0513e9f83efd3be8b64d25df22eb9e8bb223540b3718095c2b38c |
Close
Hashes for hypersync-0.4.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f22eee6ca30010e46baf8a167608cb04b873706319316b1b801c101c3ae21a8d |
|
MD5 | 2cb843168847ef38612517f640ea33ad |
|
BLAKE2b-256 | 698125f1971ee820a6de26928dd98e82ca8f1340a0bdb556aeffa3f3c8f83876 |
Close
Hashes for hypersync-0.4.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 917c50a39af3eaf009f65e778b0ed1975ba08d73bd225be3b9c2b8ca4b40af69 |
|
MD5 | 573df8f1b0b9e0d19cbd7d91e365b500 |
|
BLAKE2b-256 | 55dbfbca3119bedebdfa5cf42d98ace4a98fffed7238cfc5dd9bbb54929fe47f |
Close
Hashes for hypersync-0.4.0-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9c285d5b7169b5eecb1c35f0fd2846adf26e2d17221550cc22d4f4a0f0e84e5 |
|
MD5 | b05b637a72c5be7c17fd7223268319c4 |
|
BLAKE2b-256 | e6e88d5d32635aaee8d4fbc4069b595bb2ff0337dfdd334a5acbe558a685b118 |
Close
Hashes for hypersync-0.4.0-cp312-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e0251a917fb2494a209c31404fb7ddd7bd0d8e7aaa238ef2fca3ff75afd7417 |
|
MD5 | 5554166e405ef40e43069c4ffdbbf057 |
|
BLAKE2b-256 | c85c34c5d9f913556da2cc84e40d5039d0f21f755dbea017c89b46d076d409ee |
Close
Hashes for hypersync-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96abb872905a8ee4554277c26f9d1ceb5377663f230abb82e601e184dbd00186 |
|
MD5 | dd5b8d972cc2663b530fb978e2d8eb84 |
|
BLAKE2b-256 | d16d993c484ea953b09c318bd742daff9d677d2b9c3e64ca50dcf1710fb2852b |
Close
Hashes for hypersync-0.4.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2129c592367bf5052961732d0d6dd9ed1899546a378022613f5a663681ac53e |
|
MD5 | 4cc4bffe56827ea109d2b75c0a424d4e |
|
BLAKE2b-256 | b1a7846b3e495a95981e8f80275d555f26766118feffafabd5b56858a727cdec |
Close
Hashes for hypersync-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1637bcc970ebdbe5f94502125ec30cecef8e44cecf5dbe6124c7f2ab0d063f11 |
|
MD5 | b0a6578ea7b42a5b78022137084d82ef |
|
BLAKE2b-256 | 5a22c1019c1fada168aa85ac9dabcadd19497f712f3813a6d158b8aa6998a04d |
Close
Hashes for hypersync-0.4.0-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0c06f203537fb6160b3cd3eb13cae63c0e5a17e42558bee2d3977f2a1718a73 |
|
MD5 | ae4fd6a8afb1d6b08f76d529e17d23c2 |
|
BLAKE2b-256 | 0d255a6720e3012e67ca852ef358eeac0a13b40642ccb1e3e5b6e1db7cbec5f2 |
Close
Hashes for hypersync-0.4.0-cp311-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fcaf8c9275d21b806203bb2c0899d08dc3988e312023356c24c631ea693a4fa |
|
MD5 | ec900da1c8edb44ffd743156c30aa0af |
|
BLAKE2b-256 | 453d9b54a31e7ae0e63e546683c88f73e43eb094e8c410e092db4372994d3606 |
Close
Hashes for hypersync-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ca0cba5cf8ad3fc0e2270c37e3bbe31b4552f40e87404b5101f90b92687476c |
|
MD5 | bb6441d36da7453acc48993ff01b6658 |
|
BLAKE2b-256 | 8be407ecb0fdf38c8ee0b1f9d4d969de4a937dae34b2980796c26b31b2cf2fd2 |
Close
Hashes for hypersync-0.4.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c63839a6ed915ab2722d25313ec2d2b7aea817f591131766f03a2f7d9364ddae |
|
MD5 | 8444eff6dfc7f48f5390896bd9e52c23 |
|
BLAKE2b-256 | 53f482e6985a851caf0fa40777785dbe9abfa873b5d97def018f701bc04b0da6 |
Close
Hashes for hypersync-0.4.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ef28c32e8e1e825b8a6b26ba40591b3ec783a7f81968bbba9bb12e41d18087b |
|
MD5 | 9b275565ae743d6a4f919a822678df6c |
|
BLAKE2b-256 | 3caf56c33598d285231260212dfe1e4f875efff5db16a5a2e329c1fa5e9cc444 |
Close
Hashes for hypersync-0.4.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76e627df521fb9154407bbf94382dc7c15f6fe66194ca7f3fcf6d86027c55d43 |
|
MD5 | 1e1cec1321fa6b82b3af3aa36c55a11a |
|
BLAKE2b-256 | 708eca0405af9530c481718a35da66c3c6df88ef3b16886f0db9433dd64df5f9 |
Close
Hashes for hypersync-0.4.0-cp310-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a53baf249e819604ee5f4f31648386b70dd2e8d6827cfad1e39479784245822d |
|
MD5 | 15c2aa841a129cd30a2e35d4b50599b7 |
|
BLAKE2b-256 | f2dd8b40a14d84b155669ffff1e435e66185df2940fe8750e4205cde355ad734 |
Close
Hashes for hypersync-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62bfb8fa7391355427232309f02f6e70ab74b244c983a813f4e6ffa5392f97c5 |
|
MD5 | b6c66dfee8c496cd7ab3a16f4c8147de |
|
BLAKE2b-256 | 52f4eb5859b5e4f9236ded8b3cf2f1a93945a6295c1cd25e0e1fd88d42a024f3 |
Close
Hashes for hypersync-0.4.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1efaf5245b13d420e51b56dafec4b56b379dd77a8f44fae4b6a4fb710a3d0b9d |
|
MD5 | d5f48480ab522751abdd74aca6933c64 |
|
BLAKE2b-256 | 3f80f1db1bb0394b86ad5a79fe315bbbf66c76d78002599236bb61150fe4d646 |
Close
Hashes for hypersync-0.4.0-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fa33fb43bd60f87f1b32abe4d01a8fa729b64e34cb1c784de09ba8b3582f8e1 |
|
MD5 | 5459101099212c0f15a7a448472de259 |
|
BLAKE2b-256 | cc7ad415aa28a89fab93bc9739ae738b17a87377bf7b8e1c03146ada3e0041e1 |
Close
Hashes for hypersync-0.4.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c13109791966a8c4ef84719b60633e88d2130b2cc3df8c26dbf2ff8cdc387c0 |
|
MD5 | 9901a2a43334db81a89f6aaf1304d858 |
|
BLAKE2b-256 | b58106b2f67724dd4096fe7c65833362f86f90966c467e416f110ca36f040db0 |
Close
Hashes for hypersync-0.4.0-cp39-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a8fe42d0a232c657bf7657d0aa11791eec86c1156e5dfa10f0e7a94b2a43a5c |
|
MD5 | de1fdd8009a69a949ddcae840e754cad |
|
BLAKE2b-256 | 96ace8a84b31b0051a10d929c21e3d336ea718b471ca6e0429b11ae2031d328d |
Close
Hashes for hypersync-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 617297b689440a3b39ed7afbcf3c28b3adba65d2ddc9e78b4b8d0855ec8d7601 |
|
MD5 | c210aa06e143c04051cfe2d7c458ed23 |
|
BLAKE2b-256 | c62db9d9c49a4ccf599a01beb1dd8eee75c17230654407771151e85d840def85 |
Close
Hashes for hypersync-0.4.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a587d0a1bee9825ddf3728c13fe9f03b7a53d1cbbc402775f7e2a937fb2787b |
|
MD5 | a8d416fc90b7c9c8e6e7bfae5c60fd8d |
|
BLAKE2b-256 | 940cbc583ea7d21b818ee2a37127c9d40974cdfab1cd3b86bba6e778604e2ea5 |
Close
Hashes for hypersync-0.4.0-cp38-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82eaa647547d3f4ade067e2af49e64748ef192c2c5a6489c9032970d8d2f2993 |
|
MD5 | 11e820d34c543b8000eb32556c02ece6 |
|
BLAKE2b-256 | d237bde2b1724203b3386e9d36ea86089215ad99c8bbaacba9f573da6012cbd7 |
Close
Hashes for hypersync-0.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bb51dcce3188961d2b849eaeee11ff3f3ec1640133a258191f8a5c78778b3fe |
|
MD5 | a96d886ff11e52410c6903198ca96449 |
|
BLAKE2b-256 | 6f04e35466b4cacf69adc7ac853aa15e63711b7321955365d7537811d3f4762d |