#!/usr/bin/env bash # vim: set ft=sh: set -euo pipefail URL="http://{{ geth_rpc_addr }}:{{ geth_rpc_port }}/" METHOD="$1" shift if [[ -z "${METHOD}" ]]; then echo "No method specified!" >&2 exit 1 fi if [[ -n "${@}" ]]; then PARAMS=$(printf '%s,' "${@}") PARAMS="${@%%,}" else PARAMS='' fi PAYLOAD="{ \"id\": 1, \"jsonrpc\": \"2.0\", \"method\": \"${METHOD}\", \"params\": [${PARAMS}] }" curl -s -X POST \ -H "Content-type:application/json" \ --data "${PAYLOAD}" \ "${URL}" | \ jq -e '., if .error != null then null|halt_error(2) else halt end'