2022-07-21 19:39:53 +00:00
|
|
|
package rpcclient_test
|
2020-03-03 15:59:21 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2020-06-01 21:26:37 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
2022-07-21 19:39:53 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
2020-03-03 15:59:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func Example() {
|
|
|
|
endpoint := "http://seed5.bridgeprotocol.io:10332"
|
2022-07-21 19:39:53 +00:00
|
|
|
opts := rpcclient.Options{}
|
2020-03-03 15:59:21 +00:00
|
|
|
|
2022-07-21 19:39:53 +00:00
|
|
|
c, err := rpcclient.New(context.TODO(), endpoint, opts)
|
2020-03-03 15:59:21 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2024-02-26 19:17:16 +00:00
|
|
|
addr, err := address.StringToUint160("NUkaBmzsZq1qdgaHfKrtRUcHNhtVJ2hTpv")
|
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)
|
|
|
|
}
|