Skip to main content

GetAccountAtBlockHeight Access API Method

Gets an account by address at the given block height

Updated on
Oct 4, 2023

GetAccountAtBlockHeight Access API Method

Parameters

Address
bytes
REQUIRED
The address of the account to retrieve
BlockHeight
integer
REQUIRED
The specific block height at which to retrieve the account

Returns

account
object
An object containing the details of the account
address
string
The account address
balance
integer
The account balance
keys
array
An array of keys associated with the account
public_key
string
The public key
sign_algo
integer
The signing algorithm used
hash_algo
integer
The hashing algorithm used
weight
integer
The weight of the key
sequence_number
integer
The sequence number of the key
contracts
object
An object containing the details of the contracts associated with the account
PrivateReceiverForwarder
string
The PrivateReceiverForwarder contract
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
14
func main() {
15
16
// Requires authenticating before making the request. Refer to Intro Page on how Authentication can be done.
17
client, err := getAccessClientWithBasicAuth("ENDPOINT-NAME", "TOKEN_GOES_HERE")
18
ctx := context.Background()
19
if err != null {
20
log.Fatalf("err: %v", err)
21
}
22
23
// get latest (sealed) block
24
latestResp, err := client.GetLatestBlock(ctx, &access.GetLatestBlockRequest{IsSealed: true})
25
if err != null {
26
log.Fatal("get latest block failed: ", err)
27
}
28
29
// Get Account At Block Height
30
height := latestResp.Block.Height - 100
31
address, err := hex.DecodeString("18eb4ee6b3c026d2")
32
if err != null {
33
log.Fatalf("err: %v", err)
34
}
35
accountHeightResp, err := client.GetAccountAtBlockHeight(ctx, &access.GetAccountAtBlockHeightRequest{Address: address, BlockHeight: height})
36
respJSON, err := json.Marshal(accountHeightResp)
37
if err != null {
38
log.Fatalf("err: %v", err)
39
}
40
fmt.Println("Get Account At Block Height response:", string(respJSON))
41
}
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free