Get Nonce Account
Nonce Account
package main
import (
"context"
"fmt"
"log"
"github.com/blocto/solana-go-sdk/client"
"github.com/blocto/solana-go-sdk/rpc"
)
func main() {
c := client.NewClient(rpc.DevnetRPCEndpoint)
nonceAccountAddr := "DJyNpXgggw1WGgjTVzFsNjb3fuQZVMqhoakvSBfX9LYx"
nonceAccount, err := c.GetNonceAccount(context.Background(), nonceAccountAddr)
if err != nil {
log.Fatalf("failed to get nonce account, err: %v", err)
}
fmt.Printf("%+v\n", nonceAccount)
/*
type NonceAccount struct {
Version uint32
State uint32
AuthorizedPubkey common.PublicKey
Nonce common.PublicKey
FeeCalculator FeeCalculator
}
*/
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Only Nonce
package main
import (
"context"
"fmt"
"log"
"github.com/blocto/solana-go-sdk/client"
"github.com/blocto/solana-go-sdk/rpc"
)
func main() {
c := client.NewClient(rpc.DevnetRPCEndpoint)
nonceAccountAddr := "DJyNpXgggw1WGgjTVzFsNjb3fuQZVMqhoakvSBfX9LYx"
nonce, err := c.GetNonceFromNonceAccount(context.Background(), nonceAccountAddr)
if err != nil {
log.Fatalf("failed to get nonce account, err: %v", err)
}
fmt.Println("nonce", nonce)
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22