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.1.tar.gz
(44.2 kB
view hashes)
Built Distributions
Close
Hashes for hypersync-0.5.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e54b69db7a032ea2ed847f5fe08b00f9d2ff34cd045f9f03c3442236f4664f90 |
|
MD5 | 7a10e54eacc5609556a75003c5cb67b2 |
|
BLAKE2b-256 | 5793f53072ae27cce1ff84fdbe3ce0ee8018bf2e6f5a79dd3c1b11345f57c8d8 |
Close
Hashes for hypersync-0.5.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d9b85dfd4c4b0a8038ebd3a0388da9cb9f6d988b08bf45ece550372025847f9 |
|
MD5 | 0d6943ae13d718d5b475e28f2f28ff65 |
|
BLAKE2b-256 | ec30fdf10663b13403657862b8dd91edb01b38ce0db7c1d0d1e6fb8d61991399 |
Close
Hashes for hypersync-0.5.1-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 850146aa17c9430caa16459aff71e464b1e51ae5023f59c920522ca3c0590769 |
|
MD5 | 212305005c858d57f100b0c551f352cf |
|
BLAKE2b-256 | 112fb392507eaca27f4c661b648cdf5ce7a8b3deeb84b53347fe6ed89ba87d5e |
Close
Hashes for hypersync-0.5.1-cp312-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d45557e4a09917ee832e92fb687f5b35e6c69cc39990e57b0c2a80a131a8ac4 |
|
MD5 | d96ba2025f5c6d8831eec75140d0f9ca |
|
BLAKE2b-256 | f349ff61fb886ac04d869ee4d8af050ce5d5d594a9fd58cbbeb9cd92070262fa |
Close
Hashes for hypersync-0.5.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccf202a214dd858c16d7c0e3d405080b204d91bc4521fe875024f1b8c80145fd |
|
MD5 | 793162a1451f128cae84864c6c94db41 |
|
BLAKE2b-256 | 6f3f3fd6fe9900b63e8dc261c707d53327e75e23eae6b94cc6e4d5c967559d07 |
Close
Hashes for hypersync-0.5.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76ed0d8db5dc937c44d1085848cd6f229664de5191ac4e72f38f111b83189e18 |
|
MD5 | 98b8d6974aee2a5f0c58907204bc22a0 |
|
BLAKE2b-256 | e47a0f19b453f47140988683b535b8ea4c48de51343ed217af7ceaddeb08cc2a |
Close
Hashes for hypersync-0.5.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44c83305c543492629a8d98591340774a5167e5ffa5ad90bf9c34894c027cde7 |
|
MD5 | 8fc86959d11442a51a978b30395580fc |
|
BLAKE2b-256 | fafd6f83c626afe9000393eab4ed722e9d401cd634cc77ca0036314e723bc8aa |
Close
Hashes for hypersync-0.5.1-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc1d6c4720d72f8f7873dd707bb5ebcbc58ee332218b1830585cf057750f4b10 |
|
MD5 | f8fec4b5ebce065153bde1efe2269f6f |
|
BLAKE2b-256 | a7b3e7e08a8b7584f3194a06aa2211ea94bdb39dd8738cf4bad03482e16a5b92 |
Close
Hashes for hypersync-0.5.1-cp311-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ec6de14f7b0415991b407ec2ec70fa0ea0d608dc22c2bd91e6a0ed789f3e5f3 |
|
MD5 | 7206a58d1b74f60e40a54186b83fe22b |
|
BLAKE2b-256 | c602ce92b786b2a305b8c396fd0c89102c0f34a52da6976452a849a5ce3f6072 |
Close
Hashes for hypersync-0.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4a1e3dcdf0e0dc060813fd935b0d83c100d441be974466561d5cb2e0d98019b |
|
MD5 | 140083bf5be20119158c27095472f998 |
|
BLAKE2b-256 | 4b51cf1d45ee63994a0c2e3876684294cfd2221ab1843dd3000402d5e5e3307d |
Close
Hashes for hypersync-0.5.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f5be9c4b50bfaa0ecfb467eef74162345de0f43c56f5018570621d4fee05fee |
|
MD5 | 14ef17d1e88a8d1121ed76ebfdbd59d4 |
|
BLAKE2b-256 | c3639c41a3bdeb16ef8dd5ee97fa179a40df713df767aa5d14adfecda18ce502 |
Close
Hashes for hypersync-0.5.1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89165119bce2fb13ee642e9f0b342e15dc841b64d88308d841d88faa37761ed5 |
|
MD5 | 1be4fc9b3b08e9681f350413f23eb4e2 |
|
BLAKE2b-256 | 43ad8af7c33f111f5fde9a35e7ff8d6e12f54010ba27e1ed640c22a44f43753e |
Close
Hashes for hypersync-0.5.1-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dac26a2bb783b6c2979fda0d036da5d25d3940ebf3cb81370873f868210a2ed |
|
MD5 | 0e67997a4a5b3fe0d5feb9f0d08a1c03 |
|
BLAKE2b-256 | 96518a898badaac3dcd165583b8d0e9a67fae1d7f48fa8ddea43a308061fbf58 |
Close
Hashes for hypersync-0.5.1-cp310-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff2d949759f3915e2148cb6a3bfd0a026902425daa5c1b204900a8bc11aedfde |
|
MD5 | 962fd676f7c2c14d82846bf49ecd841e |
|
BLAKE2b-256 | 8305c40d3ae06aa15d5b5e45e27960c202a1c4cf87c1d171ccfad360e73a8e33 |
Close
Hashes for hypersync-0.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14205130cccc6cc2589327a4ce93ee62d809574b77a4e5211332c3f8bcf8a77f |
|
MD5 | 54dfcbfa9d98e452101fb57815d0f342 |
|
BLAKE2b-256 | ed9a8e2677ac6efce6ce0339f2dc1d33f1dda991626eacceed266fe05b33064b |
Close
Hashes for hypersync-0.5.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82fdd11c460d609e257af8f66883e2c2d5d04a6cd188db093ede5981084dfac7 |
|
MD5 | 781b0c9c5f2e81904b1de2bf41b5e5e5 |
|
BLAKE2b-256 | b93cfc91d8932e6b908b24a8f8482c75af23fc434aeb656e96bf3ae51055cb5a |
Close
Hashes for hypersync-0.5.1-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc04286a4cec95a72995af9d9b0b98afcd513ca8c50d6765d3e6a4a3a8d149df |
|
MD5 | f229e2f8f3e9a9256ad63302983fe728 |
|
BLAKE2b-256 | b30172e4d76bf23054dfa21c96f1d91028bf006afaaf78448f11e9615db88fa0 |
Close
Hashes for hypersync-0.5.1-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4108a771b81e40e5d3fe05e2aecaff3985ea5e1bdfe1d49933265fa61303280 |
|
MD5 | b007995ae4b4a71a07b693ce869c88f0 |
|
BLAKE2b-256 | c213620c7cfa6e5fe8d4b731836a4cc662bf3b199baed27201e0cddf91ce2740 |
Close
Hashes for hypersync-0.5.1-cp39-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2ad3dc9ca2608a689f9c6c86d9018b32429475438f18554fe797c8bed4742f9 |
|
MD5 | dc3579b695676631db3e006bc7fe9ea6 |
|
BLAKE2b-256 | 3619aad1a34db74eea837b8b37c3773ac2c27bedaafcf0efcada455705abeda7 |
Close
Hashes for hypersync-0.5.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85104dd7f3acbb7a203d2a04293b23770eba3b9cd12f176b2f7c0f06c1f33ecf |
|
MD5 | c45f4506ca4a46615d5c254865edf8b2 |
|
BLAKE2b-256 | 3b18b2763ec8272c755e00e56878f34465d4d8d6d5fb2b498896d1f2ac6e2e64 |