Skip to main content

GetBlockByHeight Access API Method

Loading...

Updated on
Oct 04, 2023

GetBlockByHeight Access API Method

Parameters

Height
string
REQUIRED
Loading...

Returns

block
object
Loading...
id
string
Loading...
parent_id
string
Loading...
height
integer
Loading...
timestamp
object
Loading...
seconds
integer
Loading...
nanos
integer
Loading...
collection_guarantees
array
Loading...
collection_id
string
Loading...
signatures
array
Loading...
reference_block_id
string
Loading...
signer_indices
string
Loading...
signatures
string
Loading...
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 != nil {
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 != nil {
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