Skip to content

Instantly share code, notes, and snippets.

@ccamel
Created January 31, 2025 22:20
Show Gist options
  • Save ccamel/f8aea954bc73d5cad3f33812085b3b88 to your computer and use it in GitHub Desktop.
Save ccamel/f8aea954bc73d5cad3f33812085b3b88 to your computer and use it in GitHub Desktop.
Bash sorcery to summon all WASM contracts from the Axone chain and unveil their real nature
#!/bin/bash
set -e -o pipefail
node="https://api.dentrite.axone.xyz:443/rpc"
contractInfoKey=$(echo -n "contract_info" | xxd -p -u) # 636F6E74726163745F696E666F (https://github.com/CosmWasm/cw-minus/blob/main/packages/cw2/README.md)
for code_id in $(
axoned query wasm list-code --node "$node" -o json \
| jq -r ".code_infos[].code_id"
); do
for address in $(
axoned query wasm list-contract-by-code "$code_id" --node "$node" -o json \
| jq -r ".contracts[]"
); do
metadata=$(axoned query wasm contract "$address" --node "$node" -o json)
raw_version=$(
axoned query wasm contract-state raw "$address" "$contractInfoKey" --node "$node" -o json \
| jq -r '.data' \
2>/dev/null \
|| echo ""
)
if [[ -n "$raw_version" ]]; then
version=$(
echo "$raw_version" \
| base64 -d 2>/dev/null \
| jq 2>/dev/null \
|| echo "{}"
)
else
version="{}"
fi
info=$(
jq -s '.[0] + .[1]' \
<(echo "$version") \
<(echo "$metadata")
)
echo "$info" | jq
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment