Docs
  • StakePool
  • Avail
    • RPC
    • Faucet
    • Live Peers
    • Snapshots
      • Avail
  • Namada
    • RPC
    • Live Peers
    • Snapshots
      • Namada
  • Polygon
    • Binaries
      • Run a Node
      • Monitoring Grafana
      • Alert Message Api
      • Monitoring Blocks Heimdall and Bor
      • Monitoring logs
    • Kubernetes
      • Technical documentation
      • control pane cluster
      • worker cluster
      • Run a node
      • Files
      • Access the Kubernetes Dashboard
      • Access the Kubernetes Dashboard Grafana
      • Monitoring logs
    • Erigon
      • Run a Node
    • Snapshots
      • Polygon
    • Scripts
      • Block Hash
      • Bor Status
      • Checkpoint Notifier
      • Checkpoint with prometheus
      • Manage Bor
      • Peer Delivering
      • Polygon Validator Participation Analyzer
      • Rpc Update
      • Span Participation
    • RPC
    • Faucet
    • Live Peers
Powered by GitBook
On this page
  1. Polygon
  2. Scripts

Block Hash

This Bash script is designed to compare the hash of a specific block from the Heimdall blockchain on your local instance with the hash of the same block obtained from an external API.

#!/bin/bash


latest_block_height=$(curl -s localhost:26657/status | jq -r '.result.sync_info.latest_block_height')


hash_value_local=$(curl -s "localhost:26657/block?height=$latest_block_height" | jq -r '.result.block_meta.block_id.hash')


hash_value_api=$(curl -s "https://heimdall-api.polygon.technology/blocks/$latest_block_height" | jq -r '.block_meta.block_id.hash')


echo "Hash of the block (Local): $hash_value_local"
echo "Hash of the block (API): $hash_value_api"

if [ "$hash_value_local" = "$hash_value_api" ]; then
    echo "The hashes are equal."
else
    echo "The hashes are different."
fi

Requests Installation:

Run the script in an environment with curl and jq installed.

sudo apt-get install jq 

Script Execution:

Make the script executable using chmod +x script.sh

Run the Script:

In the terminal or command prompt, navigate to the directory where the script is located. Execute the script using the following command:

./script.sh

PreviousScriptsNextBor Status

Last updated 3 months ago