forked from tonkeeper/tonapi-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (43 loc) · 1.1 KB
/
main.go
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"context"
"fmt"
"log"
"github.com/tonkeeper/tonapi-go"
)
const myAccount = "EQBszTJahYw3lpP64ryqscKQaDGk4QpsO7RO6LYVvKHSINS0"
func printAccountInformation(myAccount string) error {
client, err := tonapi.New()
if err != nil {
return err
}
account, err := client.GetAccount(context.Background(), tonapi.GetAccountParams{AccountID: myAccount})
if err != nil {
return err
}
fmt.Printf("Account: %v\n", account.Balance)
balances, err := client.GetAccountJettonsBalances(context.Background(), tonapi.GetAccountJettonsBalancesParams{
AccountID: myAccount,
})
if err != nil {
return err
}
for _, balance := range balances.Balances {
fmt.Printf("Jetton: %v, balance: %v\n", balance.Jetton.Name, balance.Balance)
}
items, err := client.GetAccountNftItems(context.Background(), tonapi.GetAccountNftItemsParams{
AccountID: myAccount,
})
if err != nil {
return err
}
for _, item := range items.NftItems {
fmt.Printf("NFTs: %v\n", item.Metadata)
}
return nil
}
func main() {
if err := printAccountInformation(myAccount); err != nil {
log.Fatalf("error: %v", err)
}
}