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.3.tar.gz
(44.3 kB
view hashes)
Built Distributions
Close
Hashes for hypersync-0.5.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a170fb768cb9fe82ea361740d35430b9f15518573ac330035a287999064d5f1 |
|
MD5 | dd268ef2a5e7a4944f2de9d69bc3c929 |
|
BLAKE2b-256 | 1d22e5be79272b9f9edb9bde9c52176230ee0076c23d6787173fd316c15f50d2 |
Close
Hashes for hypersync-0.5.3-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86f27e76c1c6c56e7c223445194969820017346744acc873659242c5844a08cf |
|
MD5 | dab458edd63b27d23201c8a7c277f6fc |
|
BLAKE2b-256 | 355d99807ef308d29d2b637292e4cd516d7e806c59a5b1574f1fcc8edacc80e3 |
Close
Hashes for hypersync-0.5.3-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5da680fe3309dae476dbc5b22363840fd66b5d108dbb0bc822e453cf3f123247 |
|
MD5 | 63f69091ab013ee988e320813e9e24c1 |
|
BLAKE2b-256 | f620a6e1ac7704028955d16f0c5cb95b8f48ea76b84d3240af209463e1dc8d90 |
Close
Hashes for hypersync-0.5.3-cp312-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a92e1088e2d48202658a6a78f7afc2b569762a4c7537a55fce5b6cbbe0faa95 |
|
MD5 | eb674f87c8836715b8336909edd7d8f5 |
|
BLAKE2b-256 | 7f2cd2adb0722cba313c4163db492f69cf63e5d4b4533c97f18dbdcd6c988068 |
Close
Hashes for hypersync-0.5.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 060ff9509e30faac23f9d65a9aae11353bfad01cef5f2d702e5ca3f1e8feee5c |
|
MD5 | ee41d68a8eaa6155e44fdeefd5e582c6 |
|
BLAKE2b-256 | 81b5eda299a4182c3e0f2955c1ae2e47999a5f009b6c1515d44b3a1a756f6041 |
Close
Hashes for hypersync-0.5.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1eb06add0a9a8a93b6e9b624e245e81d15f81ad0fcd748e61b7dfc01a1c8a714 |
|
MD5 | b54ac47d1f1ee00c358aa82f7fc2d6a1 |
|
BLAKE2b-256 | ac6e3e9f19144c59c970b93d473d4915f8b5d06fa2bf11e3609ff8bd1ab23f9b |
Close
Hashes for hypersync-0.5.3-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09d8d228f49d1a7305870489b55475057e7b992cc9faef9a098bddbb8e55e341 |
|
MD5 | 495398b6ae8a915afddd68c20c4cdecd |
|
BLAKE2b-256 | 4a6ef1b0d6ea93dc89943f1210299f4eafd3ea35a463f76d2fa6d7c77326f818 |
Close
Hashes for hypersync-0.5.3-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f856073c07d6b46289b01d1b6f03472e6d983a1be18937c6e204b7cf2bd9050 |
|
MD5 | 6e71fb23d6e93788e7e31d715e611874 |
|
BLAKE2b-256 | 809f25d617055b4890d67a26fd9b0f8a7509a321ce2372a2db8fd2210228ada4 |
Close
Hashes for hypersync-0.5.3-cp311-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 000fdd0c0c6d8324ffe97ecc12472eb4e333f92ba4699235377631f1f380c1b0 |
|
MD5 | 8c6d69e7dea712a00a9002f0f2d0920c |
|
BLAKE2b-256 | 0e1baa886af4b59f76533ef34a368565e5b6b3addaae67ec463a94b7a2c073d8 |
Close
Hashes for hypersync-0.5.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aac29b6a1e0d2e6e7b83623b82faed0f9de29cb022a2ef32185d30b4b6891d3e |
|
MD5 | d9fadf5efab66e99143d061a1293dadb |
|
BLAKE2b-256 | a798cc635f8031da0caa9d2ddd4f73d57b639d422d65d499eefeaf7ceccf5a2c |
Close
Hashes for hypersync-0.5.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c0fceed416685ab7772509d3e1905617c74d3038905d4e152aa16ff45ee09b3 |
|
MD5 | 51144d64994dd48838e8e19094bd765a |
|
BLAKE2b-256 | e53faf23f8ad231d1db2385f180efe49a6e88b0f816b4d3e6a32c6ba2266f67d |
Close
Hashes for hypersync-0.5.3-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33ea33a0c442913e5c600e939e5c5dd8a3d626c1f47508a8808f0d83d3486109 |
|
MD5 | 9e27171234b576c24d236f52dd2b97cf |
|
BLAKE2b-256 | acca5de1e80eb14b44e179af9216253f6b8d67df44a3b52de0550928d99a7801 |
Close
Hashes for hypersync-0.5.3-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e970f40d83cd9638f2ec424ddfd6e6ed3362f018290c472e595655d20558b323 |
|
MD5 | e21a67ea90b643f326c22622dd70ffe8 |
|
BLAKE2b-256 | df760c67f2df3d695283d2667253fab0bae7a7afd75d6f847153236ad4a4c83b |
Close
Hashes for hypersync-0.5.3-cp310-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac6f513df0dd22ba659c38a6563635d37d618696686d702163dbc4b709f55cd8 |
|
MD5 | c25f6cfc41c54fd6be6333a60bec6b29 |
|
BLAKE2b-256 | 8d2cc4fb00c31ec04d93f37651d74c44c166ff3a49d7d8377e3a53606929808c |
Close
Hashes for hypersync-0.5.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44f6a8a6bb06586d44accb71566dc15ea4b3db30374c791edf929f135272ca20 |
|
MD5 | 5313093d3e952aee7b4c95ab21d7ba28 |
|
BLAKE2b-256 | 5c2989ef1b243d398bf3bf3febb48502806cb1e3366075b74b45afa5c1ac1eba |
Close
Hashes for hypersync-0.5.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 824c1a1b2d68edb506a06205a66e69fc287e7bc620f6944c7f5fa30479121bb9 |
|
MD5 | 9f4daafac5617a618d7ef36d6fc250bb |
|
BLAKE2b-256 | 6c06e8c8badf081204f8f14b96ac0634ea740999a9236f89af80b49243a34d93 |
Close
Hashes for hypersync-0.5.3-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2dba361b894b79a2ff4493a0c6db79ef8436a7115061188cc1c7053f415b8552 |
|
MD5 | 13ea345af9ba452494523f933250d00c |
|
BLAKE2b-256 | a4e8657e44abc16c64738c7c93ffee57b02d603700ae6280d7c663e64e8c74e4 |
Close
Hashes for hypersync-0.5.3-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bffa23ece6779b69f7d8887e07c94c5d1f4f5f9eeb66409a6ef6603168b1a1c |
|
MD5 | 2cbdbf234df69ac0f7cbaf3ef35a2d2b |
|
BLAKE2b-256 | c42d70744073c0161ee44e1f0b6404e940927dfa8d47bd09c25605c8310c7ac7 |
Close
Hashes for hypersync-0.5.3-cp39-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91fd6e053031ac3d68d214eba5328949a81d93068ed165712b8bfe66f431e0e8 |
|
MD5 | c86429c9db9096be9a3be57ed21e919f |
|
BLAKE2b-256 | 53aa6b2db9b3f68accb4b87e94b58b2968f7908674f8c99405be7d71534ecd5f |
Close
Hashes for hypersync-0.5.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e0f7f92af8a5c5445bd6d956d47c44a3077ccc3235c38927095ddbbfc021c29 |
|
MD5 | 9bc91280d5f3334da9980c61bcdf83a0 |
|
BLAKE2b-256 | 5ef645008943f34bed0a470151f3d6522bf0e54d5c3afd4e2607285900d9c90f |