Created
March 22, 2024 11:08
-
-
Save wbnns/2ad08b9b7230807d855515e9c1018300 to your computer and use it in GitHub Desktop.
Get the current block number on Base using Basescan
This file contains 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
#!/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×tamp=$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