-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.go
59 lines (50 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"
"fmt"
"log"
"os"
"time"
"github.com/1inch/1inch-sdk-go/constants"
"github.com/1inch/1inch-sdk-go/sdk-clients/nft"
)
/*
This example demonstrates how to swap tokens on the EthereumChainId network using the 1inch SDK.
The only thing you need to provide is your wallet address, wallet key, and dev portal token.
This can be done through your environment, or you can directly set them in the variables below
*/
var (
devPortalToken = os.Getenv("DEV_PORTAL_TOKEN")
)
func main() {
config, err := nft.NewConfiguration(nft.ConfigurationParams{
ApiUrl: "https://api.1inch.dev",
ApiKey: devPortalToken,
})
if err != nil {
log.Fatalf("failed to create configuration: %v", err)
}
client, err := nft.NewClient(config)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
ctx := context.Background()
chains, err := client.GetSupportedChains(ctx)
if err != nil {
log.Fatalf("failed to GetSupportedChains: %v", err)
}
fmt.Println("GetSupportedChains:", chains)
time.Sleep(time.Second)
nftsByAddress, err := client.GetNFTsByAddress(ctx, nft.GetNftsByAddressParams{
ChainIds: []nft.GetNftsByAddressParamsChainIds{
constants.EthereumChainId,
constants.GnosisChainId,
},
Address: "0x083fc10cE7e97CaFBaE0fE332a9c4384c5f54E45",
})
if err != nil {
log.Fatalf("failed to GetNftsByAddress: %v", err)
}
fmt.Println("GetNftsByAddressParams:", nftsByAddress)
time.Sleep(time.Second)
}