Skip to content

Instantly share code, notes, and snippets.

@wbnns
Created March 22, 2024 11:08
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 wbnns/2ad08b9b7230807d855515e9c1018300 to your computer and use it in GitHub Desktop.
Save wbnns/2ad08b9b7230807d855515e9c1018300 to your computer and use it in GitHub Desktop.
Get the current block number on Base using Basescan
#!/bin/bash
# Get the current Unix timestamp
timestamp=$(date +%s)
# Make the request and parse the response for the block number
blockNumber=$(curl -s "https://api.basescan.org/api?module=block&action=getblocknobytime&timestamp=$timestamp&closest=before&apikey=yourApiKey" | jq -r '.result')
echo $blockNumber
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment