Skip to main content

GetBlockHeaderByID Access API Method

Gets a block header by ID.

Updated on
Oct 4, 2023

GetBlockHeaderByID Access API Method

Parameters

Id
string
REQUIRED
The block id

Returns

block
object
The details of the block
id
string
The unique identifier of the block
parent_id
string
The ID of the parent block
height
integer
The height of the block within the blockchain
timestamp
object
An object containing the details of the timestamp associated with the block
seconds
integer
An integer representing the number of seconds since a specific reference point
nanos
integer
An integer representing the additional nanoseconds that complement the seconds value
payload_hash
string
The hash of the block's payload
view
integer
The view number associated with the block
parent_voter_ids
string
A list of voter IDs associated with the parent block
parent_voter_sig_data
string
The signature data associated with the parent voter IDs
proposer_id
string
The ID of the block's proposer
proposer_sig_data
string
The signature data associated with the block's proposer
chain_id
string
The ID of the blockchain
parent_voter_indices
string
The indices of the parent block's voters
Request
1
package main
2
3
import (
4
"context"
5
"fmt"
6
"log"
7
8
"github.com/onflow/flow/protobuf/go/flow/access"
9
)
10
11
func main() {
12
13
// Requires authenticating before making the request. Refer to Intro Page on how Authentication can be done.
14
client, err := getAccessClientWithBasicAuth("ENDPOINT-NAME", "TOKEN_GOES_HERE")
15
ctx := context.Background()
16
if err != null {
17
log.Fatalf("err: %v", err)
18
}
19
// Get Latest (sealed) blockHeader
20
headerResp, err := client.GetLatestBlockHeader(ctx, &access.GetLatestBlockHeaderRequest{IsSealed: true})
21
if err != null {
22
log.Fatal("get latest block header failed: ", err)
23
}
24
25
// Get Block Header by ID
26
headerResp, err = client.GetBlockHeaderByID(ctx, &access.GetBlockHeaderByIDRequest{Id: headerResp.Block.Id})
27
if err != null {
28
log.Fatal("Get Block Header by ID failed: ", err)
29
}
30
fmt.Printf("Get Block Header by ID: %x \n", headerResp.Block.Id)
31
32
}
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free