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.4.tar.gz
(44.2 kB
view hashes)
Built Distributions
Close
Hashes for hypersync-0.5.4-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d2f03dca5cc260c84cb53b1accb8cad4dfd76dbe024365471d510f686725b60 |
|
MD5 | 0754831843665d14c82b7c6116dace45 |
|
BLAKE2b-256 | 68474f9716638df5f4381ecb8676ca0ca891b787d4f922cd0c04039a16c9a873 |
Close
Hashes for hypersync-0.5.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed6602de3a656a877741e2288ef25830edbdbb9b5048434a8b84ec1147ac225f |
|
MD5 | 52487bfb306e804af2aac2111bc4723f |
|
BLAKE2b-256 | 9ce45c67bbdb46b18e0337049396a7362b682865cefc6d07ace07cffccc325da |
Close
Hashes for hypersync-0.5.4-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6714eaa0a5a467012417746656a62a984573a34c06b49bbdabb89667a7a22cd6 |
|
MD5 | a1e056e079e23193b4051394ea4882c0 |
|
BLAKE2b-256 | 718c8110e02c8df2f3ec09b02d180f6b6f59dfbfe6ae9fb1a6bc185d451585f6 |
Close
Hashes for hypersync-0.5.4-cp312-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aea5a9c1dd119eb1a7a118bb90d829d052796b813e3683a8fac35d35a5d33214 |
|
MD5 | 4cd3c1517cb6c9dae991161d11b3e457 |
|
BLAKE2b-256 | 736da92c9ac03042c4468bdfb215bc8e1e4dc58cb2f9ccb5440fb2d8d513a268 |
Close
Hashes for hypersync-0.5.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdf9812cfd3c7a91c257ccf214903d14f2a78a43a7b5a21fe2151bd4afaa135e |
|
MD5 | a3cbc633893f7407c48f379421a3a9dc |
|
BLAKE2b-256 | 44d1a3354e7ef570f4e472b07a89117280735ee9f3171a83dbd1913dc7ec7ec1 |
Close
Hashes for hypersync-0.5.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2da34d3fd7895a19db18596fa9b631f0254f55d8bf1299899dac63f06973893 |
|
MD5 | 4824e640c28558d0defc73f12574462a |
|
BLAKE2b-256 | dec93636e0460ff992e355d22dc84f2306c1eb1156794f1f6f5f7af8504e71fd |
Close
Hashes for hypersync-0.5.4-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef12ce14fa2b2d569b7067b29ff326c83cefecf1fd7c34631f37c3bf63dc4cf1 |
|
MD5 | b2d4f990c35c89ef623a442fd049ba41 |
|
BLAKE2b-256 | 79a601e7401d4c6071dc412b1d9304e7bad3cf7bd1ab5b215ab6ab1d01d65f30 |
Close
Hashes for hypersync-0.5.4-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b6f39f8578340d8fb3a652096aec0bfd25c8472cbc674ad56d44903e13bc8fe |
|
MD5 | 0bcc5be763687d0f09c219342eb7c0f6 |
|
BLAKE2b-256 | 6fa6c22ea3f9efad1561c26804ead5c103597a09a7df5b287738bb8e24d4cc0a |
Close
Hashes for hypersync-0.5.4-cp311-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7809f80c11de22120cecc2f0cb9ffc64dba0c4cd3384058ff05206076a2451ba |
|
MD5 | f784dba2e5452e5154b953cf4e7eda3b |
|
BLAKE2b-256 | 1250fe2f72843ec3412f6acc762674d2168e81514c9807200f6ccf7e7d9c009b |
Close
Hashes for hypersync-0.5.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22ee1116d4abbe998e7a9955c6158b01053c3484e4a5f51374b7b11a18697dd5 |
|
MD5 | 20dab0b57a57b5f4294b2bfce479e6a1 |
|
BLAKE2b-256 | e0f36d1dc79708a1533859aafd66b29db505b1bcbf583e43564ce550e82e814c |
Close
Hashes for hypersync-0.5.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cddb773d775eacb7fba28f70c4b7ab53952757fac37da2c68723e7f2de0bfaf |
|
MD5 | a5ba7658a10391898ffdd0e970015e34 |
|
BLAKE2b-256 | a9935041feccad0a75569a6340fbc92f7980c3b890a5f37fed2b396e7275167f |
Close
Hashes for hypersync-0.5.4-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec30ae95931fd5aacd945ebf10dd13eea51c44f285f1b95c9b804395ecd5f460 |
|
MD5 | 70c3c798dc0d5dc10dc3b18e8e3ce8f4 |
|
BLAKE2b-256 | 67a17460988dc0c63bd6683b4f3281c8dcae6ca5beab70257f156dd61fd2d7db |
Close
Hashes for hypersync-0.5.4-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03403e894e90307a83cf973de5b4b61d71b152187ca81e43e66d03a7151ec38c |
|
MD5 | 3c049af0c575659c3b053dac7edd6db1 |
|
BLAKE2b-256 | 9249a19eab5c373d1fc3ff38973ba86390709fd179ae2ae37135a65a6428c174 |
Close
Hashes for hypersync-0.5.4-cp310-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41d40dad247285cce732e2ccc171d24ac775f7b413d6bf9982b019c96c58505d |
|
MD5 | 4b5335467bfc5321d1d9524c90baca24 |
|
BLAKE2b-256 | 2d801184f5714414882c98fe4cc232dacd450e88d6f87725e225ae8f89586f73 |
Close
Hashes for hypersync-0.5.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8129e2a16fac77a0edfc054551fa901ea3789d8981c212c345d133568bb38b07 |
|
MD5 | 80d21cf476688524cdf30a227da88525 |
|
BLAKE2b-256 | 353e059e2b407c0d79bab60971fa001042b9f2ebac33d66400a605a1b4037ca0 |
Close
Hashes for hypersync-0.5.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da4aa8a13a742009222899e28a3da9f528b4123446f1d44778493305efbec66f |
|
MD5 | 2d2a13336b7dd59d64cf520052d5c410 |
|
BLAKE2b-256 | 081b7f03eb747e867a3493f4fc538516834a250c05e310c7bacac980f063124b |
Close
Hashes for hypersync-0.5.4-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c2f32abb3c5b9c9bbc96561e3accc8d58677c6f0b52fddae5fb58c74ba4f675 |
|
MD5 | 70cc5d54f27c68dd8f9b649cc3260aea |
|
BLAKE2b-256 | b579c4438f518b72921b24d8d102ebfc4d3a4c56825d828310d091dadb13350e |
Close
Hashes for hypersync-0.5.4-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e75000e26a010ea12864f473a8dec256446a766ba165848f7d60caf56bc73c85 |
|
MD5 | 55d9ba2940cf73b12497fb8e07c9a2b1 |
|
BLAKE2b-256 | 4b3cf07eddd1436aa902a0a8656e25fc98f41a8dc6afe523332d18272fab8978 |
Close
Hashes for hypersync-0.5.4-cp39-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccd4a3545282d17b75a867959c4daffa9fbeb1c1a91a11c5875d0504b21de2a0 |
|
MD5 | 309a4318c90db256107497031dda6fe2 |
|
BLAKE2b-256 | 1f845a305d02629d3cbc199f533fd269bdb2b9f1396848002095b6989e37846b |
Close
Hashes for hypersync-0.5.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c75297f91a07503f52eddbf3b81416105c346f7687146b6be4a2b2a97e47af0e |
|
MD5 | 8311b357d7b2f0a9a3e279d16f9cddc2 |
|
BLAKE2b-256 | 58afcea3c25c6b34bfe996b7151b25c2ca3088c45aac866bb197ef00cea0acd9 |