Skip to content

Instantly share code, notes, and snippets.

@Sjors
Created April 21, 2025 13:35
Show Gist options
  • Save Sjors/e748615ac38bbebf959544fea74e3121 to your computer and use it in GitHub Desktop.
Save Sjors/e748615ac38bbebf959544fea74e3121 to your computer and use it in GitHub Desktop.
Find block containing the biggest OP_RETURN
#!/bin/bash
# First OP_RETURN is expected in March 2014 (~290,000)
# https://arxiv.org/pdf/1702.01024
n=`bitcoin-cli getblockcount`
record=0
for height in $(seq 0 $n)
do
if (( $height % 1000 == 0 )); then
echo "Checking block $height..."
fi
hash=`bitcoin-cli getblockhash $height`
biggest=`bitcoin-cli getblock $hash 2 | jq '[.tx[].vout[] | select(.scriptPubKey.type == "nulldata") | .scriptPubKey.hex | length / 2] | max'`
if (( biggest > record )); then
record=$biggest
echo "Block $height: ~$record"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment