mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-20 17:41:24 +00:00
d22286cbbc
It doesn't affect anything yet, but it's going to be used in the future for network-specific behavior. It also renames short '--timeout' form to '-s' avoiding conlict with '-t' used for '--testnet'.
40 lines
778 B
Go
40 lines
778 B
Go
package client_test
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
|
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
|
)
|
|
|
|
func Example() {
|
|
endpoint := "http://seed5.bridgeprotocol.io:10332"
|
|
opts := client.Options{Network: netmode.MainNet}
|
|
|
|
c, err := client.New(context.TODO(), endpoint, opts)
|
|
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("ATySFJAbLW7QHsZGHScLhxq6EyNBxx3eFP")
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
resp, err := c.GetNEP5Balances(addr)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
fmt.Println(resp.Address)
|
|
fmt.Println(resp.Balances)
|
|
}
|