mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 23:33:37 +00:00
9d3258495f
Signed-off-by: Roman Khimov <roman@nspcc.ru>
45 lines
778 B
Go
45 lines
778 B
Go
package rpcclient_test
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
|
)
|
|
|
|
func Example() {
|
|
endpoint := "https://rpc.t5.n3.nspcc.ru:20331"
|
|
opts := rpcclient.Options{}
|
|
|
|
c, err := rpcclient.New(context.TODO(), endpoint, opts)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
err = c.Init()
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
if err := c.Ping(); err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
addr, err := address.StringToUint160("NUkaBmzsZq1qdgaHfKrtRUcHNhtVJ2hTpv")
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
resp, err := c.GetNEP17Balances(addr)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
fmt.Println(resp.Address)
|
|
fmt.Println(resp.Balances)
|
|
}
|