Skip to main content

GetEventsForBlockIDs Access API Method

Retrieves events for the specified block IDs and event type.

Updated on
Oct 4, 2023

GetEventsForBlockIDs Access API Method

Parameters

Type
string
REQUIRED
The type of event
BlockIds
bytes
REQUIRED
The blockids for which the events is to be retrieved

Returns

results
array
A list of events
block_id
string
The ID of the block that contains the event
block_height
integer
The height of the block that contains the event
block_timestamp
object
The details of the block's timestamp, including the following properties:
seconds
integer
The seconds component of the timestamp
nanos
integer
The nanoseconds component of the timestamp
Request
1
package main
2
3
import (
4
"context"
5
"encoding/hex"
6
"encoding/json"
7
"fmt"
8
"log"
9
10
"github.com/onflow/flow/protobuf/go/flow/access"
11
)
12
13
func main() {
14
15
// Requires authenticating before making the request. Refer to Intro Page on how Authentication can be done.
16
client, err := getAccessClientWithBasicAuth("ENDPOINT-NAME", "TOKEN_GOES_HERE")
17
ctx := context.Background()
18
if err != null {
19
log.Fatalf("err: %v", err)
20
}
21
22
// Get Events For HeightRange
23
eventType := "A.7cc345e1a0fc4283.JoyrideGameShim.FinalizeTransaction"
24
25
blockID1, err := hex.DecodeString("32e10a29b636e6c226183779ef4f8292975af0a6c3c6762c44c9da2c99a38953")
26
if err != null {
27
log.Fatalf("err: %v", err)
28
}
29
30
blockID2, err := hex.DecodeString("33be7f692135e102f16d654adf8ea65b969b706eca9f8d3b3feb46b62884c871")
31
if err != null {
32
log.Fatalf("err: %v", err)
33
}
34
35
blockIds := [][]byte{blockID1, blockID2}
36
37
eventsResp, err := client.GetEventsForBlockIDs(ctx, &access.GetEventsForBlockIDsRequest{Type: eventType, BlockIds: blockIds})
38
if err != null {
39
log.Fatal("get events for block IDs failed: ", err)
40
}
41
respJSON, err := json.Marshal(eventsResp)
42
if err != null {
43
log.Fatal("get events for block IDs failed: ", err)
44
}
45
fmt.Println("GetEventsForBlockIDs response:", string(respJSON))
46
47
}
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free