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.0.tar.gz
(44.2 kB
view hashes)
Built Distributions
Close
Hashes for hypersync-0.5.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac1a83f230590bc5d3ccb09d1651aea825d981c5e13d08f92feebb7b48145c12 |
|
MD5 | 0f3e45210c8506131eb113138cb97924 |
|
BLAKE2b-256 | 8b29e29c36802c13d8c4bad242040972d00228fd74cf92ffe41d7fc518171a54 |
Close
Hashes for hypersync-0.5.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da7c2bdd90b80437fe1eff38d326a4f02174baa9424eba530e53b5659dbf959f |
|
MD5 | 86af804956053d333d8a11800f570092 |
|
BLAKE2b-256 | f5a286b51e891305a96d6c508f290b4d5be7faf66a50be76b47b412792af960a |
Close
Hashes for hypersync-0.5.0-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 864d42d7eaa64bb9f205a4d0270f9a027a205ff18ffff433500e55190ee81e3e |
|
MD5 | d5f5a9bbdde89354872d913a53946dba |
|
BLAKE2b-256 | 2a2bd61c77a29b0a9e5cbfe098fcc2971814179d6f0175749b19054e57d544e6 |
Close
Hashes for hypersync-0.5.0-cp312-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40f601b5732ee3883ea1ad681d380b421ab55f4d2c0663ccacd56bbcda4a4ce1 |
|
MD5 | a432bffbc5d421dd5ba4fe16b51e7e96 |
|
BLAKE2b-256 | e04e24a128cc693eaa5a90b434f7076d6727078474b212e5af1d7452e0947991 |
Close
Hashes for hypersync-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 964144a570e7fabac9d87ccffc536c06a7d9c984a6b053308a2d3f8716872bf9 |
|
MD5 | 01032527a0bee2bc20660be67bb53502 |
|
BLAKE2b-256 | 1f03f94555ec4bb0d0c8364bc91a736d5e8c4ba17c90369a5c18d8daade2b0f2 |
Close
Hashes for hypersync-0.5.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4b2ed88c5ddc1f0198c1d28bb7ca3eb1f5e6e9f008c9184d512e3b4ccc1616c |
|
MD5 | b68b1f16475441bf0112e974a38b214e |
|
BLAKE2b-256 | ffb67a2fa827ff5ecd5a7a98ced1cc02b4b6197ae489975fdef93d393d59ad5e |
Close
Hashes for hypersync-0.5.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a95e695251a32989c97308dd24416afe583c8f15a3c85fc214d1f7624aa0a79 |
|
MD5 | c8d06cad6bd15a595671bcb3ad9caf70 |
|
BLAKE2b-256 | 261e33a2c41a63982c3647d6bf5127bf1a3ddc09b354fbf83590f0fe775c8a7c |
Close
Hashes for hypersync-0.5.0-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3836ce24b716150c85bb7407142d8f20ad67ad5134b045b4797e5dc97269f4a4 |
|
MD5 | 46a74c194291830ea77fbb15b174962f |
|
BLAKE2b-256 | 27c8b459d5715db4b9b37bed493a32155256c2a2b973046fa3cc9b5847ca0da4 |
Close
Hashes for hypersync-0.5.0-cp311-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 203d3072ecf20a778b29b3b211515cc95e86bd2ad90cbe95a44a986f03281d83 |
|
MD5 | 5c70767d0395ad7eab9b0310525668e9 |
|
BLAKE2b-256 | 548eeda144edda2c4144d6541905598c2c1c5eccebd3e303725853140b0d1cac |
Close
Hashes for hypersync-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b2820902442b87cf5b2ba95489f15191e390a0ccf605363e57c2976aab80b33 |
|
MD5 | 2d2e3d8e63723c9258c5ce99964c2027 |
|
BLAKE2b-256 | 4e042363a28739c784ce92c5ec6d8e778e41c341af96ca3ca07efb2c63c1b9b4 |
Close
Hashes for hypersync-0.5.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9b6814b6c07a4302e003b8f3634b7b48f85decf85f283a5c0ed2b6d439845ea |
|
MD5 | ff434af65251641f887c2656c4905b0a |
|
BLAKE2b-256 | 2d7436086ef7c33c80544ce17eaf9a9d72c02b9fec1396575b81da4cd7ccc18c |
Close
Hashes for hypersync-0.5.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1374d7e93fa510ca5f6bdbe9d9ad89ec088468cfc50fe281f69d41838a5a4519 |
|
MD5 | 8da6b710ce202fd541811ebc16167340 |
|
BLAKE2b-256 | 9d3a1b98f3d40ab04411d55752e9e24e378933b373a9eaa60125bc8979a46ac3 |
Close
Hashes for hypersync-0.5.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d193e999bbf053b56557f4f5a717d8a94a7e3d7cb96a90dda13570bbeeac7728 |
|
MD5 | 4b944876b33e4d29aa754dba6595c058 |
|
BLAKE2b-256 | 04402c7e84d3277bd78f9b2afaabf1c02be144d8cce2d00f4bb55b8d4766334f |
Close
Hashes for hypersync-0.5.0-cp310-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24e35ba09f54107bc69d96d7b7478503ada01f42cc12ddc97e9435ce916aa5d6 |
|
MD5 | 6ae691e8eecd060acda8b23e27693075 |
|
BLAKE2b-256 | f30cc92e073615ee2347c55f3fe65d8dd6ef9fa8d9162a7f4556d42313f2ed95 |
Close
Hashes for hypersync-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1c6a8c2ed72310328be88faf623f94a6aa2fb0dd14c5fe88f0d68a4084c16ee |
|
MD5 | c2842995e54fdf4dcd59e935915d367f |
|
BLAKE2b-256 | 48ebcb33a5ef22274cb953201fe3513bdb42470b87f9ec708d107c2d7f3b4d09 |
Close
Hashes for hypersync-0.5.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 036621ea013902e3b9d55f86f74e97b4b35d0521f76e2a1428fbefc68bc4ad79 |
|
MD5 | 21660e511a8e63ae2b4aaa4ca8c41e18 |
|
BLAKE2b-256 | 509c8020065c44fb1b306788c682ba5c4e02abd00d5feb1d3f367fc994e53d2f |
Close
Hashes for hypersync-0.5.0-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0c5a2c7904ad0ee90acfbd0bee21f3a56c3bd84a0d41a0f8ebcb956ba4f61b7 |
|
MD5 | 3744f87feaa0dd97b491144c9b8f30be |
|
BLAKE2b-256 | 6bfc19cec2e78b905ee5019d37b24717eb20435a176fad36938a2f7235a4e480 |
Close
Hashes for hypersync-0.5.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfa15b709b6ad1bf723db6c308f583a817c13067a9562b7f904b3deaa13600fa |
|
MD5 | 3e79818de99418980b29dc1044198072 |
|
BLAKE2b-256 | e25817bdd867609b87560fe70ea5b40b6424400a13d0370502710c31f4ad535c |
Close
Hashes for hypersync-0.5.0-cp39-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c69ca3112160d5a77d8ebae6cd817cd528f576188108a900d2601c183155b82b |
|
MD5 | f6127093832ae2a06f6cf355004cabc8 |
|
BLAKE2b-256 | ce5bbc3d8978cde5bb78b0c4d3a031b807993fecda332d4b935e7273b5ab915b |
Close
Hashes for hypersync-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8da0bb93e71fa60b119bab053c02851d0977666e5d80196ab7529ed30411d391 |
|
MD5 | 8a82be2561977432bbf0bedac58d15ad |
|
BLAKE2b-256 | 48e7c0215efbd3409e0aed9573118446895c73ffc25808a1b2b193887e44cbf0 |