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