Skip to content

A client to interact with gxchain implemented in GO

Notifications You must be signed in to change notification settings

gxchain/gxclient-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gxclient-go

A client to interact with gxchain implemented in GO

Usage

import "github.com/gxchain/gxclient-go"

APIs

Constructors

//init client
func NewClient(actPriKeyWif, memoPriKeyWif, accountName, url string) (*Client, error)

Keypair API

//Generates the key pair
func GenerateKeyPair(brainKey string) (*KeyPair, error)
//Export public key from private key
func PrivateToPublic(priWif string) (string, error)
//Check if privateKey is valid or not
func IsValidPrivate(priWif string) bool
//Check if publicKey is valid or not
func IsValidPublic(priWif string) bool

Chain API

//broadcast transaction
func (client *Client) broadcast(stx *types.SignedTransaction) error
//broadcast transaction
func (client *Client) broadcastSync(stx *types.SignedTransaction) (*types.BroadcastResponse, error)
// GET ChainId of entry point
func (api *API) GetChainId() (string, error)
// Gets dynamic global properties of current blockchain
func (api *API) GetDynamicGlobalProperties() (*DynamicGlobalProperties, error)
// Get block by block height
func (api *API) GetBlock(blockNum uint32) (*Block, error)
//get block objects
func (api *API) GetObjects(objectIds ...string) ([]json.RawMessage, error)
//get block object
func (api *API) GetObject(objectId string) (json.RawMessage, error)
//send transfer request to entryPoint node
func (client *Client) Transfer(to, memo, amountAsset, feeSymbol string, broadcast bool) (*types.TransactionResult, error)

Faucet API

//register account
func Register(faucet, account, activeKey, ownerKey, memoKey string) (*types.Transaction, error)

Account API

// get account info by account name
func (api *API) GetAccount(account string) (*types.Account, error)
// get accounts info by account names
func (api *API) GetAccounts(accounts ...string) ([]*types.Account, error)
//get account balances by account name
func (api *API) GetAccountBalances(accountID string, assets ...string) ([]*types.AssetAmount, error)
//get account_ids by public key
func (api *API) GetAccountsByPublicKey(publicKeys string) ([]string, error)

Asset API

// get assets corresponding to the provided symbols or IDs
func (api *API) GetAssets(symbols ...string) ([]*Asset, error)
// get assets corresponding to the provided symbol or ID
func (api *API) GetAsset(symbol string) (*Asset, error)

Staking API

//Get staking programs
func (api *API) GetStakingPrograms() ([]*types.StakingProgram, error)
//create staking
func (client *Client) CreateStaking(to string, amount float64, programId, feeSymbol string, broadcast bool) (*types.TransactionResult, error)
//update staking by stakingId
func (client *Client) UpdateStaking(to, stakingId, feeSymbol string, broadcast bool) (*types.TransactionResult, error) 
//claim staking by stakingId
func (client *Client) ClaimStaking(stakingId, feeSymbol string, broadcast bool) (*types.TransactionResult, error)

About

A client to interact with gxchain implemented in GO

Resources

Stars

Watchers

Forks

Packages

No packages published