2020-03-03 15:59:21 +00:00
|
|
|
package client_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2020-06-01 21:26:37 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
2020-03-03 15:59:21 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Example() {
|
|
|
|
endpoint := "http://seed5.bridgeprotocol.io:10332"
|
2020-10-14 15:13:20 +00:00
|
|
|
opts := client.Options{}
|
2020-03-03 15:59:21 +00:00
|
|
|
|
|
|
|
c, err := client.New(context.TODO(), endpoint, opts)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2021-09-08 10:02:14 +00:00
|
|
|
err = c.Init()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2020-03-03 15:59:21 +00:00
|
|
|
if err := c.Ping(); err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2020-06-01 21:26:37 +00:00
|
|
|
addr, err := address.StringToUint160("ATySFJAbLW7QHsZGHScLhxq6EyNBxx3eFP")
|
2020-03-03 15:59:21 +00:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2020-11-24 08:14:25 +00:00
|
|
|
resp, err := c.GetNEP17Balances(addr)
|
2020-06-01 21:26:37 +00:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
fmt.Println(resp.Address)
|
2020-03-03 15:59:21 +00:00
|
|
|
fmt.Println(resp.Balances)
|
|
|
|
}
|