KardiaChain Docs
Search…
⌃K

Golang SDK

Old Doc

Installation

go get github.com/kardiachain/go-kaiclient

Initializing

func SetupKAIClient() (*Client, context.Context, error) {
ctx, _ := context.WithCancel(context.Background())
cfg := zapdriver.NewProductionConfig()
logger, err := cfg.Build()
if err != nil {
return nil, nil, fmt.Errorf("Failed to create logger: %v", err)
}
// defer logger.Sync()
client, err := NewKaiClient("http://10.10.0.251:8551", logger)
if err != nil {
return nil, nil, fmt.Errorf("Failed to create new KaiClient: %v", err)
}
return client, ctx, nil
}

Endpoints

LatestBlockNumber

LatestBlockNumber(ctx context.Context) (uint64, error)

BlockByHash

BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)

BlockByNumber

BlockByNumber(ctx context.Context, number uint64) (*types.Block, error)

BlockHeaderByNumber

BlockByNumber(ctx context.Context, number uint64) (*types.Block, error)

BlockHeaderByHash

BlockHeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)

GetTransaction

GetTransaction(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)

GetTransactionReceipt

GetTransactionReceipt(ctx context.Context, txHash common.Hash) (*kai.PublicReceipt, error)

BalanceAt

BalanceAt(ctx context.Context, account common.Address, blockHeightOrHash interface{}) (string, error)

NonceAt

NonceAt(ctx context.Context, account common.Address) (uint64, error)

SendRawTransaction

SendRawTransaction(ctx context.Context, tx *types.Transaction) error

Peers

Peers(ctx context.Context) ([]*types.PeerInfo, error)

NodeInfo

NodesInfo(ctx context.Context) ([]*types.NodeInfo, error)

Datadir

Datadir(ctx context.Context) (string, error)

Validator

Validator(ctx context.Context, rpcURL string) (*types.Validator, error) {}

Validators

Validators(ctx context.Context) ([]*types.Validator, error)