-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.go
59 lines (47 loc) · 1.43 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
51
52
53
54
55
56
57
58
59
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"os"
"github.com/1inch/1inch-sdk-go/constants"
"github.com/1inch/1inch-sdk-go/sdk-clients/balances"
)
var (
devPortalToken = os.Getenv("DEV_PORTAL_TOKEN")
)
const (
mainWalletAddress = "0x1C17622cfa9B6fD2043A76DfC39A5B5a109aa708"
tokenAddress1 = "0x0d8775f648430679a709e98d2b0cb6250d2887ef"
tokenAddress2 = "0x58b6a8a3302369daec383334672404ee733ab239"
spender = "0x58b6a8a3302369daec383334672404ee733ab239"
)
func main() {
config, err := balances.NewConfiguration(balances.ConfigurationParams{
ChainId: constants.EthereumChainId,
ApiUrl: "https://api.1inch.dev",
ApiKey: devPortalToken,
})
if err != nil {
log.Fatalf("Failed to create configuration: %v\n", err)
}
client, err := balances.NewClient(config)
if err != nil {
log.Fatalf("Failed to create client: %v\n", err)
}
ctx := context.Background()
response, err := client.GetAllowancesOfCustomTokensByWalletAddress(ctx, balances.AllowancesOfCustomTokensByWalletAddressParams{
Spender: spender,
Wallet: mainWalletAddress,
Tokens: []string{tokenAddress1, tokenAddress2},
})
if err != nil {
log.Fatalf("Failed to get allowances of custom tokens by wallet address: %v\n", err)
}
responseIndented, err := json.MarshalIndent(response, "", " ")
if err != nil {
log.Fatalf("failed to marshal response: %v", err)
}
fmt.Printf("GetAllowancesOfCustomTokensByWalletAddress: %s\n", responseIndented)
}