Skip to main content

GetBlockByHeight Access API Method

Gets a full block by height.

Updated on
Oct 4, 2023

GetBlockByHeight Access API Method

Parameters

Height
string
REQUIRED
The height of the block

Returns

block
object
The block object with the following fields
id
string
The unique identifier of the block
parent_id
string
The ID of the parent block
height
integer
The height of the block
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
collection_guarantees
array
An array of collection guarantees associated with the block
collection_id
string
The identifier of a collection guarantee
signatures
array
The list of signatures associated with the collection guarantee
reference_block_id
string
The ID of the reference block
signer_indices
string
The list of indices of signers
signatures
string
The list of signatures associated with the block
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
20
// Get Block by height
21
var height uint64 = 54652420
22
blockResp, err := client.GetBlockByHeight(ctx, &access.GetBlockByHeightRequest{Height: height})
23
if err != null {
24
log.Fatal("get block by height failed: ", err)
25
}
26
27
fmt.Printf("block with height %d has ID %x\n", height, blockResp.Block.Id)
28
29
}
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free