Skip to content

Instantly share code, notes, and snippets.

@Reecepbcups
Created January 7, 2024 19:55
Show Gist options
  • Save Reecepbcups/8a5ee9cdd209601f249fc2c86b840dc8 to your computer and use it in GitHub Desktop.
Save Reecepbcups/8a5ee9cdd209601f249fc2c86b840dc8 to your computer and use it in GitHub Desktop.
Read an entire genesis file from the RPC in chunks
# ref: https://github.com/Reecepbcups/unicorn-airdrop-list-jan-7
import base64
from httpx import get
RPC = "https://rpc.unicorn.meme/genesis_chunked"
headers = {"Content-Type": "application/json"}
def get_chunk(idx: int = 0) -> str:
params = {"chunk": idx}
r = get(RPC, params=params, headers=headers)
data = r.json().get("result", {}).get("data", {})
return base64.b64decode(data)
all_text = ""
for i in range(0, 6):
text = get_chunk(i)
all_text += str(text)
with open("chunked_genesis.json", "a") as f:
f.write(all_text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment