KAI Chain

constructor

Params

Name

Type

Required

Description

client

Client

RPC client that will be used to interact with KardiaChain

Return

Return a KAIChain instance .

Methods

getBlockNumber

Get current block number

Params

None

Return

Current block number

isValidator

Check if an address is a validator or not

Params

Name

Type

Required

Description

address

string

Required

Address to check

Return

True if given address is address of validator, otherwise false.

getValidators

Get list of current validators

Params

Name

Type

Required

Description

withDelegators

boolean

Indicate if return with each validator list of delegators.

Return

List of current validators

getBlockByBlockNumber

Get block by number

Params

Name

Type

Required

Description

blockNumber

number

Required

Block number (block height) to get data

Return

Block object

getBlockByHash

Get block by number

Params

Name

Type

Required

Description

blockHash

string

Required

Block hash to get data

Return

Block object

getBlockHeaderByBlockNumber

Params

Name

Type

Required

Description

blockNumber

string

Required

Block number (block height) to get header

Return

Block header object

getBlockHeaderByHash

Params

Name

Type

Required

Description

blockHash

string

Required

Block hash to get header

Return

Block header object

newFilter

Create a new filter to watch for smart contract's events

Params

Name

Type

Required

Description

obj

object

Required

obj.fromBlock

number | 'latest'

Block number to start filter

obj.toBlock

number | 'latest'

Block number to end filter

address

string

Smart contract's address

topics

string[]

List of topics to filter.

Return

Fitler ID

newBlockFilter

Create a new filter to watch for new block

Params

None

Return

Filter ID

uninstallFilter

Uninstalls a filter with given id. Should always be called when watch is no longer needed.

Params

Name

Type

Required

Description

filterID

string

Required

ID of filter to uninstall

Return

True if the filter was successfully uninstalled, otherwise false.

getFilterChanges

Polling method for a filter, which returns an array of logs which occurred since last poll.

Params

Name

Type

Required

Description

filterID

string

Required

ID of filter to get changes

Return

An array of logs which occurred since last poll.

For filters created with kai_newBlockFilter the return are block hashes, e.g ["0x3454645634534..."]

For filters created with kai_newFilter, return array of Log

getFilterLogs

Returns an array of all logs matching filter with given id.

Params

Name

Type

Required

Description

filterID

string

Required

ID of filter to get changes

Return

See getFilterChanges

getLogs

Returns an array of all logs matching a given filter object.

Params

Name

Type

Required

Description

obj

object

Required

obj.fromBlock

number | 'latest'

Block number to start filter

obj.toBlock

number | 'latest'

Block number to end filter

address

string

Smart contract's address

topics

string[]

List of topics to filter.

Return

Array of Log

getGasPrice

Get optimized gas price

Params

None

Return

Optimized gas price in HYDRO

Static method

KAIFromHydro

Convert Hydro to KAI

Params

Name

Type

Required

Description

hydroValue

string

Required

Hydro value to convert

Return

Value in KAI

HydroFromKAI

Convert KAI to Hydro

Params

Name

Type

Required

Description

kaiValue

string

Required

KAI value to convert

Return

Value in Hydro

Last updated