I am trying to obtain the pow-hash of a block. Is there a way of doing this easy?
Thanks in advance :)
I am trying to obtain the pow-hash of a block. Is there a way of doing this easy?
Thanks in advance :)
On the go-ethereum source code, you can see that the pow-hash is the hash of the block header
// SealHash returns the hash of a block prior to it being sealed.
func (ethash *Ethash) SealHash(header *types.Header) (hash common.Hash) {
hasher := sha3.NewKeccak256()
rlp.Encode(hasher, []interface{}{
header.ParentHash,
header.UncleHash,
header.Coinbase,
header.Root,
header.TxHash,
header.ReceiptHash,
header.Bloom,
header.Difficulty,
header.Number,
header.GasLimit,
header.GasUsed,
header.Time,
header.Extra,
})
hasher.Sum(hash[:0])
return hash
}
You can using JSON RPC to get block information from free infura endpoint and pick out the hash in the block header
for example
curl -X POST \
https://mainnet.infura.io/v3/YOUR_API_KEY \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: 05e4a4b4-1476-4d79-9771-38dc56aa16e6' \
-d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x6432AA", true],"id":1}'
YOUR_API_KEY is your api key from your infura dashboard account.
Or just parsing the html output from etherscan.io :)