No project description provided
Project description
hypersync-client-python
Python package for Envio's HyperSync client written in Rust
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.0.3.tar.gz
(33.0 kB
view hashes)
Built Distributions
Close
Hashes for hypersync-0.0.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5f05d14341b9c2e750a2d006087a59be0b5aa137cbb0371e0fb9620af3efc91 |
|
MD5 | 52f66a99743e46a18afb834a69924297 |
|
BLAKE2b-256 | c52aa25902377a32428f4d462c2f1e96aa3ecce616c461d0079e9625c54ad281 |
Close
Hashes for hypersync-0.0.3-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24996c504b0dab55134fe696ccbe6e4a4e686f0ce9a8150573f25fb4715e3406 |
|
MD5 | 6f08b9d9374dfb2c80757a4227b8ece0 |
|
BLAKE2b-256 | 267d5fe0a4dad2b9ca410bd13782cfb22197c257c1522787d8ff2828cd748aa1 |
Close
Hashes for hypersync-0.0.3-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dc569a2e9d30a9c5a0e106b27ccffeff0b6c9339873dc542fc6633064628184 |
|
MD5 | 7a064bc2e783c2731b6b1f63222fcd40 |
|
BLAKE2b-256 | db66eb1418b6e49fb2975d0d5c98e6ef222b16a3836fedba7d772685646b51c5 |
Close
Hashes for hypersync-0.0.3-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d71fc38bc7d1c59dc65701eb0f8349ca625cf496e32b749ef5fdd81cb76c890 |
|
MD5 | 4828964c19cd13861042ac8bfc7f02d6 |
|
BLAKE2b-256 | bbc5d924dce5843e7018a11309c6b515eb5dd6d9b5dfcb75f81fb816c04e122e |
Close
Hashes for hypersync-0.0.3-cp312-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd73abc9632f0e6bf1ceac2e11470ea4379e2e39d72a82fc0d81fb80a94b0b57 |
|
MD5 | fdd23e725388be00137ef6284fee8d14 |
|
BLAKE2b-256 | 90982af3846a482c760451836ea6ecc9ca0b211e0ef5002066d9b5c94a1003cb |
Close
Hashes for hypersync-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c036dbd52ed47b258cb083a876c5fcf0f56f0de66fc16b0fa895405b2f66e7a |
|
MD5 | 95df93f8147360e440136d85b4a1a920 |
|
BLAKE2b-256 | 858ae45874f90817ab32ac27345fb3fb2d22c569ad201cdd87ff7cea0bfcf4e1 |
Close
Hashes for hypersync-0.0.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0822a81be07367742b50b3100539e992a37cc914f3d981aae93792735fe5b0e |
|
MD5 | f18843efc7c2cd4a1745eb358c176a84 |
|
BLAKE2b-256 | 61cb2f11dc4477e3025b858a60188a1769ca20d6021fac2e918f7ef80cdaf811 |
Close
Hashes for hypersync-0.0.3-cp312-cp312-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ae7bc566c990832cbf138cab5760f9dff12fa27ca3d138e81b0f799fc3d77cb |
|
MD5 | 4609b7a568b5bc449b6b7c58ba54acc8 |
|
BLAKE2b-256 | e0e0514a4a4fef39e96908880eaffdc9c4d0aefd59ed26c060f1b59dfd2c32de |
Close
Hashes for hypersync-0.0.3-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ced8c5e03685455a9e2bd233696fd8a4afbea9973c708ae3e77f53fb4034d15b |
|
MD5 | 803eebdf14613a75c657f61c0641579b |
|
BLAKE2b-256 | 1d4097d773ea60484076213bd28dbb83e16b407de6837b41eb6706e27080dcf5 |
Close
Hashes for hypersync-0.0.3-cp311-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d17d9e2eecf61a6ebb6021236e17435f33329d1ce0ccf41a33b615ebebfa6a9 |
|
MD5 | c7eadde575d1d5a384fb413c76bd7906 |
|
BLAKE2b-256 | fe2c05cb7938da7afb551e565200d238e10647217967f6192626ca03c4ca24aa |
Close
Hashes for hypersync-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e29ba97b3765f1ab2b773c4ec5bcc3fe4d1e0e0a4c31630081febfb137dbe59d |
|
MD5 | 3798747dd00d7b1f017254fcc7498b00 |
|
BLAKE2b-256 | 70dd9b63c640d8085f0d2d23cf46ff1122ed698ac9a5f300c3f1814115e0f6e7 |
Close
Hashes for hypersync-0.0.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b688ec50aee8dfb12845f0d3dbfa8fbc467e3bd2487638d2dcc65870bae22b6 |
|
MD5 | 22b6d8335ab6ef1d2f06228c262c8c99 |
|
BLAKE2b-256 | 955c34dd1ef194c55165e4ea056554512a95ead86ce3bd6445351b968c35b70f |
Close
Hashes for hypersync-0.0.3-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffbbca301d9ab54343995f5f3a582eac54aeb3235294941c3b99dfcba4f87d0e |
|
MD5 | b719b84caf37ad543c533ff2c3bc17f6 |
|
BLAKE2b-256 | 7655762e250e8399a39e614cdd5367e21dd2d677dd9e38ba38e98db54f640e43 |
Close
Hashes for hypersync-0.0.3-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e814744bf7b3a52c4f130835fae95479a07b54aeb45c66a1d63e4deac0864e06 |
|
MD5 | e1350c14b03a23a7ef65d1532acf5f3e |
|
BLAKE2b-256 | 8afa41c601649523dcaf35f3611b3af74b7ebcf633995ed7dec90df97249f97e |
Close
Hashes for hypersync-0.0.3-cp310-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e0f6995eee058374b4143da4ce77e6c84812acc416c6e21d0cdf4c7f33114b9 |
|
MD5 | b8465d26ae4bfbf7b3b595bc6c2d7d1e |
|
BLAKE2b-256 | 4b32e81878c6274bd95578934e5f9d7496f897497f3f3b303539bf3bf72af6b8 |
Close
Hashes for hypersync-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ab826d94e1648ea9ac9ed75c48867ebdcc5c5c5c60009e6a7be03a8f819b3f6 |
|
MD5 | 6cd0ec5518ace05bafb13b1d393e709f |
|
BLAKE2b-256 | 24ebbd5d371e4281cb20671da9cd605bd3641960a5b9294828f76edce8777225 |
Close
Hashes for hypersync-0.0.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d0679ca1c6dca5ed59ec8c2b44ff611a05beb4bbe056fd6ea86014c5cb93896 |
|
MD5 | c2fef85b96e6e8f8e74c8f297f0e7425 |
|
BLAKE2b-256 | 1f8ba6ea2905d10a3a77001c060637bed109dd54271263206d868d48b9328b5f |
Close
Hashes for hypersync-0.0.3-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59d881092632dca0d35d04cee7619a45068965e47d923c72ef1fd6cdf88bc80a |
|
MD5 | 7c70512b3dfd8844f01d3369cbfbd0b4 |
|
BLAKE2b-256 | b5b58e85991d0411b0ec61174da1656307c435f3663ec47caee399e83539a377 |
Close
Hashes for hypersync-0.0.3-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1d396412f57bef812338cba6218955a40c8ba5b574161137202e2d668e77e90 |
|
MD5 | e19d91bad0e4d527d8b66b655a7bfc1d |
|
BLAKE2b-256 | f08a585d8590a1dd2f65f80d3e7c299a99be59a30c53e02ada6913ffa980e178 |
Close
Hashes for hypersync-0.0.3-cp39-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4107e5d0551251bb4327f5a35fd65ceb35f889d9e4852e32b65a683ff8343aa8 |
|
MD5 | a2e78cf68547f8adc84fb8c1f7b35044 |
|
BLAKE2b-256 | c1aad522bb48e492ef0ae8f6792fd20683eea5c8dc4648fe0982cc385c828b32 |
Close
Hashes for hypersync-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ab215f51363e509a4e42737b1b7c2a513c6c4f273ffba5c449138f70f5ac76c |
|
MD5 | 9a7a02d2588e7d453306bbcf86186b9d |
|
BLAKE2b-256 | 240f00b4365652d735cb328d6940d4e0a17242e0cecfe7c478a119c042a0351b |
Close
Hashes for hypersync-0.0.3-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86ba8a2160437eb6ee875992afca9338fa636cd5cfbd93f7bb78916a1416252d |
|
MD5 | f9751e3743278a74986f5515f32b2455 |
|
BLAKE2b-256 | b6764425630b9d72c0288104f2fc08113783dee445022df9fc25680789b12ce2 |
Close
Hashes for hypersync-0.0.3-cp38-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1368e361daf2ece3c1436b506158b76e0a3e4741ce465ac4fa92efcdc13896d5 |
|
MD5 | 4b156822ec5bf86a65aa95477d8cd774 |
|
BLAKE2b-256 | 486624fdd2d79f542dbda06d9a56105dacb7f162af5c7a6fbe0858bb32870def |
Close
Hashes for hypersync-0.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6269d0f93e35f5b8b32b959cb905ca544c34ef880dc03f7033791c35dc5ad81c |
|
MD5 | 7be5ef0cf9afada56933dd4e9ed1372e |
|
BLAKE2b-256 | e40952174c68e1f9b123eb0000a2253b70866e59fa46392d50327dcb3b452e00 |