Skip to content

Instantly share code, notes, and snippets.

@af-afk
Created January 5, 2025 09:52
Show Gist options
  • Save af-afk/60dcc7eca418119d73e1ae259e180739 to your computer and use it in GitHub Desktop.
Save af-afk/60dcc7eca418119d73e1ae259e180739 to your computer and use it in GitHub Desktop.
EthDebugCall
#!/bin/sh -e
url="$1"
block="$2"
from="$3"
destination="$4"
[ -z "$url" ] && url="$(EthereumPickHttp)"
[ -z "$url" ] && exit 1
[ -z "$block" ] && block="$(Question 'enter block?' </dev/null | int-to-hex)"
[ -z "$block" ] && exit 1
[ -z "$from" ] && from="$(QuestionEthAddress from)"
[ -z "$from" ] && exit 1
[ -z "$destination" ] && destination="$(QuestionEthAddress contract)"
[ -z "$destination" ] && exit 1
data="0x$(Question 'ethereum data' </dev/null | stdin-strip-0x)"
[ -z "$data" ] && exit 1
input="$(cat <<EOF
{
"from": "$from",
"to": "$destination",
"data": "$data"
}
EOF
)"
request="[{\"jsonrpc\":\"2.0\",\"method\":\"debug_traceCall\",\"params\":[$input, \"$block\", {\"enableMemory\": true, \"enableStack\": true, \"enableReturnData\": true, \"withLog\": true, \"onlyTopCall\": false, \"disableStorage\": false}],\"id\":\"default\"},{\"jsonrpc\":\"2.0\",\"method\":\"debug_traceCall\",\"params\":[$input, \"$block\", {\"tracer\": \"prestateTracer\", \"tracerConfig\": {\"onlyTopCall\": false, \"withLog\": true, \"diffMode\": true}}],\"id\":\"prestate\"},{\"jsonrpc\":\"2.0\",\"method\":\"debug_traceCall\",\"params\":[$input, \"$block\", {\"tracer\": \"callTracer\", \"tracerConfig\": {\"onlyTopCall\": false, \"withLog\": true}}],\"id\":\"callTracer\"},{\"jsonrpc\":\"2.0\",\"method\":\"debug_traceCall\",\"params\":[$input, \"$block\", {\"tracer\": \"callTracerLegacy\", \"tracerConfig\": {\"onlyTopCall\": false, \"withLog\": true}}],\"id\":\"callTracerLegacy\"},{\"jsonrpc\":\"2.0\",\"method\":\"debug_traceCall\",\"params\":[$input, \"$block\", {\"tracer\": \"evmdisTracer\", \"tracerConfig\": {\"onlyTopCall\": false, \"withLog\": true}}],\"id\":\"evmdisTracer\"}]"
target="$(PlumbLargeOpen "/ethereum/$url/$from/$destination/call")"
PlumbLargeWrite $target <<EOF
$request
EOF
curl -sH 'Content-Type: application/json' -d "$request" "$url" 2>&1 \
| prettify-json \
| PlumbLargeWrite $target
AcmeGoToDot $target
AcmeMakeWindowClean $target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment