Skip to main content

GetLatestBlock Access API Method

Gets the full payload of the latest sealed or unsealed block.

Updated on
Oct 4, 2023

GetLatestBlock Access API Method

Parameters

IsSealed
boolean
REQUIRED
A boolean flag indicating whether to retrieve the latest sealed or unsealed block

Returns

block
object
An object representing the details of the block, containing the following properties:
id
string
The ID of the block
parent_id
string
The ID of the parent block
height
integer
The height of the block
timestamp
object
The details of the timestamp, containing the following properties:
seconds
integer
The number of seconds in the timestamp
nanos
integer
The number of nanoseconds in the timestamp
collection_guarantees
array
A list of collection guarantees, where each guarantee has the following properties:
collection_id
string
The ID of the collection
signatures
array
A list of string values representing the signatures
reference_block_id
string
The ID of the reference block
signer_indices
array
A list of string values representing the signer indices
signatures
array
A list of string values representing the signatures
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 Latest (sealed) block
21
latestResp, err := client.GetLatestBlock(ctx, &access.GetLatestBlockRequest{IsSealed: true})
22
if err != null {
23
log.Fatal("get latest block failed: ", err)
24
}
25
fmt.Println("Latest Block Height: ", latestResp.Block.Height)
26
}
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free