README
¶
asuleymanov/golos-go
Golang RPC client library for Golos.
Usage
import "github.com/asuleymanov/golos-go"
Example
This is just a code snippet. Please check the examples
directory
for more complete and ready to use examples.
package main
import (
"fmt"
"github.com/asuleymanov/golos-go"
)
func main() {
cls, _ := golos.NewClient("wss://golos.lexa.host/ws")
defer cls.Close()
fmt.Println("Config --> ")
fmt.Printf("%#v \n",cls.Config)
fmt.Println("")
fmt.Println("")
fmt.Println("DatabaseInfo --> ")
ans,err:= cls.API.GetDatabaseInfo()
fmt.Printf("%#v \n Error : %s\n",ans,err)
fmt.Println("")
fmt.Println("")
fmt.Println("ChainProperties --> ")
ans1,err1:= cls.API.GetChainProperties()
fmt.Printf("%#v \n Error : %s\n",ans1,err1)
fmt.Println("")
fmt.Println("")
}
Package Organisation
You need to create a Client
object to be able to do anything.
Then you just need to call NewClient()
.
License
MIT, see the LICENSE
file.
Documentation
¶
Index ¶
- Variables
- func GenerateProposalOperation(ops []operations.Operation) operations.ProposalObjects
- func JSONOpString(v []operations.Operation) (string, error)
- func JSONTrxString(v *transactions.SignedTransaction) (string, error)
- func SetAsset(amount float64, symbol string) *types.Asset
- type Client
- func (client *Client) Close() error
- func (client *Client) GetTrx(strx []operations.Operation) (*operations.Transaction, error)
- func (client *Client) SendTrx(username string, strx []operations.Operation) (*types.OperationResponse, error)
- func (client *Client) SetAsyncProtocol(value bool)
- func (client *Client) SetKeys(keys *Keys)
- func (client *Client) SigningKeys(trx operations.Operation) ([][]byte, error)
- type Keys
Constants ¶
This section is empty.
Variables ¶
var (
ErrInitializeTransport = errors.New("Failed to initialize transport.")
)
var ( //OpTypeKey include a description of the operation and the key needed to sign it OpTypeKey = make(map[operations.OpType][]string) )
Functions ¶
func GenerateProposalOperation ¶
func GenerateProposalOperation(ops []operations.Operation) operations.ProposalObjects
GenerateProposalOperation generate []Operation to ProposalOperations
func JSONOpString ¶
func JSONOpString(v []operations.Operation) (string, error)
JSONOpString generate Operations to String
func JSONTrxString ¶
func JSONTrxString(v *transactions.SignedTransaction) (string, error)
JSONTrxString generate Trx to String
Types ¶
type Client ¶
type Client struct { API *api.API Config api.Config // Current keys for operations CurrentKeys *Keys // contains filtered or unexported fields }
Client can be used to access GOLOS remote APIs. There is a function for every available GOLOS API, for example, Client.API.GetDatabaseInfo() corresponds to database_api -> get_database_info.
func NewClient ¶
NewClient creates a new RPC client that use the given CallCloser internally. Initialize only server present API. Absent API initialized as nil value.
func (*Client) Close ¶
Close should be used to close the client when no longer needed. It simply calls Close() on the underlying CallCloser.
func (*Client) GetTrx ¶
func (client *Client) GetTrx(strx []operations.Operation) (*operations.Transaction, error)
func (*Client) SendTrx ¶
func (client *Client) SendTrx(username string, strx []operations.Operation) (*types.OperationResponse, error)
SendTrx generates and sends an array of transactions to VIZ.
func (*Client) SetAsyncProtocol ¶
SetAsyncProtocol enables or disables the asynchronous operation protocol
func (*Client) SigningKeys ¶
func (client *Client) SigningKeys(trx operations.Operation) ([][]byte, error)
SigningKeys returns the key from the CurrentKeys