Last active
September 11, 2020 20:54
-
-
Save gabmontes/98af61a31aeceb0f6dafdeaf9c1d91df to your computer and use it in GitHub Desktop.
Get the time of the latest Ethereum block in one line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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