Skip to content

Instantly share code, notes, and snippets.

@gabmontes
Last active September 11, 2020 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabmontes/98af61a31aeceb0f6dafdeaf9c1d91df to your computer and use it in GitHub Desktop.
Save gabmontes/98af61a31aeceb0f6dafdeaf9c1d91df to your computer and use it in GitHub Desktop.
Get the time of the latest Ethereum block in one line
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest",false],"id":"0"}' -s http://localhost:8545| jq '.result.timestamp' | xargs -I {} node -e "console.log(new Date(Number.parseInt('{}'.substr(2),16) * 1000))"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment