From ritual-dapp-skills
Estimates block times and converts blocks to seconds for Ritual dApps. Guides TTL, lock durations, scheduler frequency, and polling window settings.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ritual-dapp-skills:ritual-dapp-block-timeThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Use a conservative planning baseline of **~350ms per block** when you do not have fresh measurements from your target deployment.
Use a conservative planning baseline of ~350ms per block when you do not have fresh measurements from your target deployment.
1 block ~= 0.35s100 blocks ~= 35s300 blocks ~= 105s (~1m45s)500 blocks ~= 175s (~2m55s)5,000 blocks ~= 1,750s (~29m10s)10,000 blocks ~= 3,500s (~58m20s)100,000 blocks ~= 35,000s (~9h43m)70,000 blocks ~= 24,500s (~6h48m)For one day:
blocksPerDay ~= ceil(86,400 / 0.35) = 246,858Before choosing production TTL/lock/scheduler values, estimate block time from recent chain data on your target RPC.
RPC_URL="${RPC_URL:-https://rpc.ritualfoundation.org}"
SAMPLE=60
LATEST=$(cast block-number --rpc-url "$RPC_URL")
OLDER=$((LATEST - SAMPLE))
LATEST_TS=$(cast block "$LATEST" --rpc-url "$RPC_URL" --json | jq -r '.timestamp')
OLDER_TS=$(cast block "$OLDER" --rpc-url "$RPC_URL" --json | jq -r '.timestamp')
uv run --quiet python3 - <<'PY' "$LATEST_TS" "$OLDER_TS" "$SAMPLE"
import sys
latest_ts = int(sys.argv[1], 0)
older_ts = int(sys.argv[2], 0)
sample = int(sys.argv[3])
avg_sec = (latest_ts - older_ts) / sample
print(f"Estimated block time: {avg_sec:.4f}s ({avg_sec*1000:.1f}ms)")
PY
If your measured value is materially different from 350ms, use the measured value in formulas below.
seconds = blocks * blockTimeSeconds
blocks = ceil(seconds / blockTimeSeconds)
Examples at blockTimeSeconds = 0.35:
ceil(3600 / 0.35) = 10,286 blocksceil(86400 / 0.35) = 246,858 blocksceil(900 / 0.35) = 2,572 blocksApply these conversions consistently in:
ttl / maxPollBlock windowsfrequency and interval tablesnpx claudepluginhub ritual-foundation/ritual-dapp-skills --plugin ritual-dapp-skillsSchedules time-delayed, recurring, or one-shot on-chain calls in Ritual dApps. Supports precompiles like ONNX, LLM, HTTP for automated workflows.
Optimizes Alchemy SDK for blockchain queries using TTL caching, parallel multi-chain fetching, and batching to cut latency and CU costs in high-volume dApps.
Fetches real-time gas prices, estimates DeFi transaction costs, analyzes patterns, predicts prices, and finds optimal windows across Ethereum and chains like Polygon.