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.1.0.tar.gz
(34.9 kB
view hashes)
Built Distributions
Close
Hashes for hypersync-0.1.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffad1759aa11784c7f1c9ca12d5f7826b70d41e6dca7143ce19289ebc235e8ea |
|
MD5 | a91a5685502c22e7dc32a83b695bc4a6 |
|
BLAKE2b-256 | 29f31072da2312820693edd8468825f8fd60825a00fa426fe80b8b36651f3193 |
Close
Hashes for hypersync-0.1.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f279fb86d9bdec5cfe886b7e755817a136e23527b9b6dc6cddb17ec419e22020 |
|
MD5 | 46cc17fc24d075efc2c96d37969d491e |
|
BLAKE2b-256 | 2c2919ca791bfdcf1d7463ba7c91e396c7e2e88af2f9ec6aa638639f1746b1ab |
Close
Hashes for hypersync-0.1.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad188d72cfce866904d2af43d1ccec4612f63a6b331059b482b317c7215b37c8 |
|
MD5 | d778dadb5fd8f7990d36b43714ccff79 |
|
BLAKE2b-256 | 3747f9e62f23a499054f4f34f62b5d524bb0b006a3e9a29c0b30363831eb820e |
Close
Hashes for hypersync-0.1.0-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cf276e64c050ee5076876e50051a8ffd29362c1edbe1aa1e0dde46951b95414 |
|
MD5 | ca67f29692d9bdadeeb792b783ebc663 |
|
BLAKE2b-256 | 86ed67c6b442f0fa27c026161162a1bce1bb291715ceb8489b506f72d50508e1 |
Close
Hashes for hypersync-0.1.0-cp312-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c356c86c9a7d88ac8f43401bfb8c9840d05f41443a26ac916a8c1f507fdc089 |
|
MD5 | 669068201cf4f54b07afb0f14cc2357f |
|
BLAKE2b-256 | 330f97d9ad223bf6e6508b691e282be4b0503ff0b8471c8b7abd82f83f560f23 |
Close
Hashes for hypersync-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb2bfc9c63f7228c5ae40326a5f499f80f20c4a1a5a9091112233ff68ce20a3e |
|
MD5 | 02fb36d028f38ebb654370d09551492b |
|
BLAKE2b-256 | 744a34d039100513b8083898581a1594cdb51947a8771a3f1352218877124e46 |
Close
Hashes for hypersync-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e23b3f05426357e5778968e9a5b9970ee0042957bbfed248635d9c55958be0f |
|
MD5 | 109d31b12a9df81526b49713210afb51 |
|
BLAKE2b-256 | 5ef0ee758c7b7478d14e83f8b48c7c68d3a9f4709a215af7da07a739d1365316 |
Close
Hashes for hypersync-0.1.0-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78111d8cebfde950f9ce5cd5f7b4954a60eb8969ed265d896e1bdc8f34c23400 |
|
MD5 | 5c75437a0a3db23281af77897d72a882 |
|
BLAKE2b-256 | 8254d481c3bba15ab4d22422f56bb3ed19a9564fb560ba90d5cb32911dab426d |
Close
Hashes for hypersync-0.1.0-cp311-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea00a9009910d512e633bc46a4037cd596d5e312d774d1d9d2b0d65dbff8450f |
|
MD5 | 72051cd58d9ce6851aa0aff0cf618174 |
|
BLAKE2b-256 | f87d153062a0e1b5c202b473063fa7e28320005d372275e1b428bb4a46b74f19 |
Close
Hashes for hypersync-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60f1b465a74fee580d029da77b90d381bd6a86adf3e8f4da43d3cdcb15136fab |
|
MD5 | 0af8a5f8e32c57cea15b239d232d30f4 |
|
BLAKE2b-256 | a163d40734fd66659f7cdb2a8ff3dd0ef970eb7ca0fab1d4779c21f5c4ff059b |
Close
Hashes for hypersync-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f097b231f97b2e56b0e80de279a5cc6abf80048ee9fbff4f73f3064577328936 |
|
MD5 | 6178fdc157828b61cbacb4645c91fc84 |
|
BLAKE2b-256 | 22d226549cc84484f27cff2bad55805854adbff739078b7db0c0ee8d35857344 |
Close
Hashes for hypersync-0.1.0-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3b8c94b691de90ec940ad6973990e83505ec4b661a3f350d5431fc32333499e |
|
MD5 | dd2d7f186392b336abb7155bf358331b |
|
BLAKE2b-256 | be0c32cafa280eeff6f435b9b045358ad561b8e4ab2a194024b732d155a98fd0 |
Close
Hashes for hypersync-0.1.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9a4299ce3e14bcc07ea26209551e77058d1bed30a3ed7cb9166dc7d1b5fbf45 |
|
MD5 | a24e9ca14453b2604cdcadd9fab9be1f |
|
BLAKE2b-256 | 57e394dbe290ddccbb0210c9f61a6eba0e4663ad641f270a28fc3c7b4445387d |
Close
Hashes for hypersync-0.1.0-cp310-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3acafff508fa7d6777b58b12053383d29ab28d7ee1e324310e2a910a59a04555 |
|
MD5 | eaa94e212715fc647e9170b5186317e7 |
|
BLAKE2b-256 | 9b4d35f3e6d86ce074c607db4711bc9c0d13d30786780fc82ea52606facc094f |
Close
Hashes for hypersync-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2d5f2b24247a09e6ad608b0a0a0314854a64060681c6eef9919005a6b547c11 |
|
MD5 | cd5dc915d91c0ecec8fce4becbf802c2 |
|
BLAKE2b-256 | da8d36658fa57c7385801c1911f44518d5050818554fcef9c3d2a04a88af4c1c |
Close
Hashes for hypersync-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a5e538360c4e6760f9464ce25608519824c55ec1926b240a71514a05fc3957b |
|
MD5 | 07dfacd1e193b4f297e57f527f1830da |
|
BLAKE2b-256 | 964d76e812c3d8f903e30d890d18594a9b007269be17ee9413279f50469d8baf |
Close
Hashes for hypersync-0.1.0-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce22330aaa95238f7a576a3fe23a89b1cc9a57045fabbbecfa9090bdb9eb1451 |
|
MD5 | a458d6f69db465bab60af79f5a65b1b9 |
|
BLAKE2b-256 | f0b18dfefb5179732b70a4846ee02117ca304871ff4a2295d8708586c952eea0 |
Close
Hashes for hypersync-0.1.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24e3579313e30ae12f9b0c25fa13455b3c641717bf214aeba1c7e49fcf738a05 |
|
MD5 | f11954da5c64cc7a16be39cd1b1e4fbb |
|
BLAKE2b-256 | ab874d431feeca230918740e67a51e2635c0d18af740e6c2f01256680a53bf08 |
Close
Hashes for hypersync-0.1.0-cp39-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e9ece359f2985beed962473cbdbf734eac8765348214a11b6d61994488ff000 |
|
MD5 | c35984c97e115b75d2c8a1d210cb438d |
|
BLAKE2b-256 | 71237e10c6b450720e038a671f9c87f0cd57bece0d517bc526cce5a5e553acf9 |
Close
Hashes for hypersync-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de059e0043efac6234f086168a81f28659223c250da394b930d4819ff9f35469 |
|
MD5 | 29b9ddc2a39c5fd917e86beddca0e130 |
|
BLAKE2b-256 | 37a67510c9cae9450b8d639566238a645a65a5d9c4acaf8b9ab1ff0e0f270d4c |
Close
Hashes for hypersync-0.1.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 293965c10bfaca06af34600c79c697dbfd743093f5960bc91b51679c94b0e07c |
|
MD5 | dde0506ce532356fa5466ddeb70240f6 |
|
BLAKE2b-256 | 99b5e1faa06b9dcbbac281ea651a103dc0e80c9c65484009b5122c8cc59b7e35 |
Close
Hashes for hypersync-0.1.0-cp38-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 835b70a45c151fa1b19b0d036976b622c9b2102e52b6f9ebcd244ef692fea7ae |
|
MD5 | 8e78a4df78738a63d48ac8b36b264abe |
|
BLAKE2b-256 | 0ec1d0124e4f4c9fd5d65bc8413eada2bdf5005c20abd7b7941ad4b619164692 |
Close
Hashes for hypersync-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8418bc5430d91fa39c1087d92af8728214a9ec5fef2f8ab6f7bad23f9f9577e9 |
|
MD5 | f618e58f3a12a1bb6b12b12ba7c6935e |
|
BLAKE2b-256 | 0960bc1f0effdb7499455c496f73368c56ab1e8c122bfe0a696997b51344131d |