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.2.1.tar.gz
(41.3 kB
view hashes)
Built Distributions
Close
Hashes for hypersync-0.2.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b840cb9016c3b5ed8a5fb8dfca9575b6203f07091a1f234c437318b56cca6b98 |
|
MD5 | 9724b8aa8f4270f9a547138b4e7092f5 |
|
BLAKE2b-256 | 42a9f435935de936b3563e473b8a22d3b084a6e314cb8b41e81131ad150d5f9f |
Close
Hashes for hypersync-0.2.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c518ab8de53c2c3e86422ebab9ca8cc0183c6d9cad1ae6b340a7e2eae00959c |
|
MD5 | 65a406beb199a441064808fff56f5e8b |
|
BLAKE2b-256 | fc3fd330d8d48b484ce7c1433f1fb39037ddd24eba5ac90fc83c3879664e2a01 |
Close
Hashes for hypersync-0.2.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51b6b16d28f15eba6a3ed494bb07eb058fe0ee4be028df7ec210014873dbe059 |
|
MD5 | 3f46e18e32a88487db9a013600d3d4da |
|
BLAKE2b-256 | 59a8c4923a2057cc3d847db887e543b35f088d0316c5f272426e3adbd803ac50 |
Close
Hashes for hypersync-0.2.1-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 602da2e3b092391ef2bb851a77275da9ad229605c01d93134923ea5addea4e5d |
|
MD5 | 28a237027881c45be5cbccde7696666a |
|
BLAKE2b-256 | 47cc851cd7c2a1ae1971bb20fdfbf7b90a52175a1d2298dad21e9641cfb66124 |
Close
Hashes for hypersync-0.2.1-cp312-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82e7be2dd636240c4917f59720a5443423a13b079de2dcc5df88dac1b329efca |
|
MD5 | 7615c75011afacb614156ad455b23a33 |
|
BLAKE2b-256 | b9a78d123e2388a1927ea75aa8f5b436aeedeaf9563eb4aea8433c6c496fd003 |
Close
Hashes for hypersync-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22ec56f2fcdc8e1468ee9a9c241c90e2ceafc5047c9fa9f2f2a6ad4ae9230e1e |
|
MD5 | da2416ca2bac6df6432317a8822a6ae4 |
|
BLAKE2b-256 | 5ac14200dbba3a168d3d1fbf10ad3df0c3cdbd52ffe843934fc85d78d86e3635 |
Close
Hashes for hypersync-0.2.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29013655a1bdcc65338845bbda703db2a1bb3750c98412112c24299a26206207 |
|
MD5 | 4357ee80840ee32f238cf3565636fc5b |
|
BLAKE2b-256 | 1f07ba97605ad796090421604570a85e724edba718719cd4500511c00fb3d775 |
Close
Hashes for hypersync-0.2.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3aca957a356fc36b33840708728d4efe36ece33e34fe48679cfa826b89c3fbb |
|
MD5 | b4ad3d7003e72237aaa7c1aacfdd098e |
|
BLAKE2b-256 | ae8a3756f11c89e0a0f81ee3d781841b40a935a82b1707fb885de3b5ddb8b7ae |
Close
Hashes for hypersync-0.2.1-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90f81efcd54f03aee87bedffc307c55c434ff397f394952b08349e610d62937f |
|
MD5 | 79dc5e0305501f7681be4d8f1f8b7252 |
|
BLAKE2b-256 | a11693773da38de86a5ac1e7a5c5aeefffb9d35d516a3e52f85196d7e4457f1f |
Close
Hashes for hypersync-0.2.1-cp311-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17d1f5cb663e7e859607283165aba34075e1e503d3ff58a426071469789dc243 |
|
MD5 | 01d0650a9034ca12d90d69c4e046f587 |
|
BLAKE2b-256 | a4c7aba805a89109e3375ae5d099eb6b814cac29ae181d460342d127d6a77266 |
Close
Hashes for hypersync-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b96894f297d9895934f94bfd39b1f964dea81932dd19561ef41c28b9e637f79b |
|
MD5 | 5b42f7b4169a32021e62c756a08a35db |
|
BLAKE2b-256 | 82416600f5da05a1e691ded7ea35f82350b78b5b8134f136bf6665e0bd3e8b4e |
Close
Hashes for hypersync-0.2.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bff998838e3ad76f51b51a97b392c400ef5cdbe1ab09f3f22707a115a904042 |
|
MD5 | 4408e4b970f0afdae98c65a68eebd019 |
|
BLAKE2b-256 | 0b3a12174e3ff398991d5bc77e3dcc6dc66e6d6fa91a8606d4f7a9f3b832a160 |
Close
Hashes for hypersync-0.2.1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f283c657963959405977d1ae2d777ff68d4f4d2004aa27faa51600f1a1e9208 |
|
MD5 | bb25f13dbaff4dcb03c79ebb4dc34f20 |
|
BLAKE2b-256 | 5b385b8479a2e4611d72c69f1395c0ffa7a238e035474832726275500a8d5fe0 |
Close
Hashes for hypersync-0.2.1-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8155344f334330fcd3da8bb2c991d564b6ce021d5bade447646e98917cbc0f9e |
|
MD5 | f84b8cd4eb8ec89b301b12eff92530bf |
|
BLAKE2b-256 | 36760af8e7c592c864bb0899a76b83f418611fc65161bb7e7e73d1d27cbae845 |
Close
Hashes for hypersync-0.2.1-cp310-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9803ae839877a2fca4e86f0e75b0cc11197a3d2d1d54e0c6aa394b762ea57a26 |
|
MD5 | 9c8b6c89414e5280a0ffe2847cc33b91 |
|
BLAKE2b-256 | b1b8e75f80b7f0137fcd9e29712044db1ef784aa7d1222b4ad447a78c6fda614 |
Close
Hashes for hypersync-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 577e1918d47c1fcab93f35b8a3b9d1c6477e16c2a63c50c8de2632e6254e5ba2 |
|
MD5 | c701263a329bb9d4a650882b363653fb |
|
BLAKE2b-256 | 9b44345085058c9f4284e299d5b29aa599a154f81900a731d98c5313c6147c0f |
Close
Hashes for hypersync-0.2.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0734a7cbffd758c3dfd598edb32a3a100e2f782fda168fd0080f03b2beaadc6 |
|
MD5 | c550f98aa6110fd1b6446690498580fd |
|
BLAKE2b-256 | fd563ff82de293081985764957d0e8b842d9800f674c19dfbee1570f9902752a |
Close
Hashes for hypersync-0.2.1-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1b23adaf981b69c168996727d1bd6024b8a500d3db55b96c54d5c704d9ae400 |
|
MD5 | 326022fb64448348eb714fae22dc35b2 |
|
BLAKE2b-256 | 55f2a31ecf33b6de8d007d78914b583a24e8f892ac2cde7939fe5cfdd2af44eb |
Close
Hashes for hypersync-0.2.1-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 600c8d40358d85d83df1f0026c22a61874c0c9dab6adc43f4cfcaf0565c24ce5 |
|
MD5 | 03bc4f0f66eb653c6521943db63d1392 |
|
BLAKE2b-256 | 152e676589bb47f5dde01f2832a138a0b8b9da1c18941a3cf206d149bc6b56d7 |
Close
Hashes for hypersync-0.2.1-cp39-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3f768e629c8df1fd4bc7801d5f0961c5b8a26a0fe854c34c931482a939a38cc |
|
MD5 | 838e89a4540ecf82a841f413350a8b38 |
|
BLAKE2b-256 | 28a5e1ee2596774826720d5cacb7fcc4c54ef7fe31f3efd02ff7872cf51fb409 |
Close
Hashes for hypersync-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90621f7888caaa2bdb21bbda88585b143ed6e622dca12ddcfff0f3bb1717ff1a |
|
MD5 | 22858d723cb7d64cb113c7d9ad8d772f |
|
BLAKE2b-256 | 8a9d32f8f7dfaf08960fd6d9a0448afb918aa55c5cbb8e08a7c8745573c1d173 |
Close
Hashes for hypersync-0.2.1-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 691480a2e543112c4a4b7f7b9a3a2e9c84e3a6f3eec4adafdefa169303df02ec |
|
MD5 | 59d051ae6d712dd993fc443a95f56916 |
|
BLAKE2b-256 | 0d92826cf36448f13dc553661ae548b84080cc77197ec63eae7ed620ada179ab |
Close
Hashes for hypersync-0.2.1-cp38-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4829fa00cfcec4b10fc7f682c68f0fb13b343bbe0e87d918419fb7c49f4dcde |
|
MD5 | 9b43f66c23ba7c0a4713321a8c13c696 |
|
BLAKE2b-256 | 6150a92a41f1c85517af3f90cd53ba9de5432eaf2a0d0b6b8b87dab653df26c4 |
Close
Hashes for hypersync-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4333b08e80f06381117029ae0835763f5167a3735db38b2803edd3b0d32daa33 |
|
MD5 | 81c51de7cfdd3014716acc4bb27d2d1d |
|
BLAKE2b-256 | bb3f4d1a441431efb534c5c7fea9a5831d1d2ffaa5a156c4a9ddbeebeced558f |