Skip to content

Instantly share code, notes, and snippets.

View Reecepbcups's full-sized avatar

Reece Williams Reecepbcups

View GitHub Profile
# Convert a ETH hex address to decimal and back
# No pre-pended 0x here
# -> [56, 160, 36, 192, 180, 18, 185, 209, 219, 139, 195, 152, 20, 13, 0, 245, 175, 48, 147, 212]
echo -n "["; echo "38a024c0b412b9d1db8bc398140d00f5af3093d4" | sed 's/.\{2\}/\0 /g' | while read -a hex; do
for h in ${hex[@]}; do printf "%d, " "$((16#$h))"; done
done | sed 's/, $/]/'
# convert back to hex
# -> 38a024c0b412b9d1db8bc398140d00f5af3093d4
#!/usr/bin/env bash
: '
Reece Williams | Nov 2024
# Requires: fzf
# - https://archlinux.org/packages/extra/x86_64/fzf/
Opens folders in your programming mono local repo in your editor or explorer.
@Reecepbcups
Reecepbcups / cosmos_release.md
Created March 5, 2024 16:19
How to perform a release on a Cosmos Chain

Cosmos Release Guide

This document outlines a step by step guide to release a binary change to node operators.

Note All releases must be tested on the testnet (Uni) before mainnet. Severe security patches may be the only exception to this rule, depending on the severity. These should be tested on testnet and execute against the bit of software changed (i.e. Wasm upgrade, make sure wasmd still works). Then move to a mainnet node, wait, then release to all.

Halting Security Patch (i.e. CW1.5.2)

Validator Update Readiness Script: https://gist.github.com/Reecepbcups/2b8f90139ccbfbe293afaa7d466b2ebf

Example Sheet: https://docs.google.com/spreadsheets/d/1TIGUb32vS6T8Qk2obQ-_HwKPMOOM6ue6HwueVo2WbTg/edit#gid=0

@Reecepbcups
Reecepbcups / cosmos_block_vested_account_staking.go
Last active August 10, 2024 15:06
Blocks vesting accounts from delegating their tokens to validators.
package decorators
// reference: https://x.com/gtx360ti/status/1760400114361725279
// Stratos VC sells $1,609,926 by staking their "locked" tokens ($DYM), earnings rewards on these vested funds
// and selling the rewards. Recouping their entire investment within 3 weeks of mainnet despite not touching
// any of the locked funds.
import (
"fmt"
// cosmrs = { version = "0.15.0", features = [ "rpc", "dev", "bip32"] }
// bip32 = { version = "0.5.1" }
// serde = { version = "1.0.130" }
// serde_json = { version = "1.0.68"}
use bip32::{DerivationPath, Language};
use cosmrs::proto::tendermint::Error;
use serde::Deserialize;
// derivation path for cosmos wallets is 118. Terra/Secret is 330, and ETH is 60.
@Reecepbcups
Reecepbcups / genesis_chunked.py
Created January 7, 2024 19:55
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:
@Reecepbcups
Reecepbcups / mintscan_get_all_txs.py
Created January 2, 2024 18:40
Gets all transactions for an address via Mintscan's beta API
# https://api.mintscan.io/dashboard
import json
from typing import List
from httpx import get
addr = "juno1lykvggsfnywqhsmqz346p567aejrn4gp06p5w4"
headers = {
"Authorization": "Bearer PRIV-TOKEN-HERE",
"Accept": "application/json",
@Reecepbcups
Reecepbcups / noisd_airdrop_bruteforce.py
Created November 13, 2023 00:09
Cosmos: Missing Mnemonic brute force
# https://x.com/kais_kat/status/1723844153685971400?s=20
# flake8: noqa
import random
import string
import subprocess
from httpx import get
# rm -rf ~/.noisd/keyring-test
@Reecepbcups
Reecepbcups / cosmos_chain_apy.sh
Last active June 25, 2024 13:46
Script to query a Cosmos chains values and return the staking APY
#!/bin/bash
LCD_URL="https://juno-api.polkachu.com"
DENOM="ujuno"
# {"pool":{"not_bonded_tokens":"2431244061010","bonded_tokens":"58093075821304"}}
BONDED=$(curl -s $LCD_URL/cosmos/staking/v1beta1/pool | jq -r '.pool.bonded_tokens') && echo $BONDED
# {"inflation":"0.100000000000000000"}
INFLATION=$(curl -s $LCD_URL/cosmos/mint/v1beta1/inflation | jq -r '.inflation') && echo $INFLATION
@Reecepbcups
Reecepbcups / validator_update_readiness.py
Created October 13, 2023 00:21
Easy to paste Cosmos chain information for upgrade coordination
# pip install httpx (or use requests)
from httpx import get
# cosmos.directory
API = "https://juno-api.reece.sh"
ENDPOINT = "cosmos/staking/v1beta1/validators?pagination.limit=1000"
URL = f"{API}/{ENDPOINT}"
get_validators = get(URL).json().get("validators", [])