Skip to content

Kardia JSON RPC API

Trinh Dang edited this page Nov 16, 2021 · 18 revisions

JSON RPC API

JavaScript API

To talk to an Kardia node from inside a JavaScript application use the Kardia Javascript SDK library, which gives a convenient interface for the RPC methods.

Golang API

We also provide a Go KaiClient to interact with these RPC methods using Go.

JSON-RPC Endpoint

Client URL
Local http://0.0.0.0:8545
Mainnet https://rpc.kardiachain.io

Go

Start Kardia network [README] (https://github.com/kardiachain/go-kardiamain/tree/master/README.md)

change the default port (8545) and listing address (0.0.0.0) with:

JSON-RPC support

Currently, the Go client of Kardia node supports JSON-RPC 2.0 via HTTP.
Additional protocols such as IPC and WS will be supported in the future.

Curl Examples Explained

The curl options below might return a response where the node complains about the content type, this is because the --data option sets the content type to application/x-www-form-urlencoded . If your node does complain, manually set the header by placing -H "Content-Type: application/json" at the start of the call.

The examples also do not include the URL/IP & port combination which must be the last argument given to curl e.x. 0.0.0.0:8545

JSON-RPC methods

The complete Postman collection with examples can be found here.

JSON RPC API Reference


node_nodeInfo

Returns information of current node which provide JSON-RPC endpoint.

Parameters

none

Returns

Object - information of current node.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "node_nodeInfo",
    "params": [],
    "id": 1
}'

// Result
{
    "jsonrpc":"2.0",
    "id":1,
    "result": {
        "protocol_version":{
            "p2p":1,
            "block":1,
            "app":1
        },
        "id":"fbd5e2afb7c0a7862b06964e29e676bf02183256",
        "listen_addr":"tcp://0.0.0.0:3000",
        "network":"",
        "version":"1.0.0",
        "channels":"20212223383000",
        "moniker":"KAI-Validator-1",
        "other":{
            "tx_index":"on",
            "rpc_address":""
        }
    }
}

node_peers

Returns a list of peers which current node connects to.

Parameters

none

Returns

Object - list of peers which current node connects to.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "node_peers",
    "params": [],
    "id": 1
}'

// Result
{
    "jsonrpc":"2.0",
    "id":1,
    "result":[
        {
            "node_info":{
                "protocol_version":{
                    "p2p":1,
                    "block":1,
                    "app":1
                },
                "id":"c60de907fd861b0f9936b74bff9d1c7f693da099",
                "listen_addr":"tcp://0.0.0.0:3000",
                "network":"",
                "version":"1.0.0",
                "channels":"20212223383000",
                "moniker":"KAI-Validator-3",
                "other":{
                    "tx_index":"on",
                    "rpc_address":""
                }
            },
            "is_outbound":true,
            "connection_status":{
                "Duration":863087178122147,
                "SendMonitor":{
                    "Start":"2020-11-30T10:04:05.3Z",
                    "Bytes":1994547550,
                    "Samples":1135242,
                    "InstRate":961,
                    "CurRate":4797,
                    "AvgRate":2311,
                    "PeakRate":293070,
                    "BytesRem":0,
                    "Duration":863087180000000,
                    "Idle":640000000,
                    "TimeRem":0,
                    "Progress":0,
                    "Active":true
                },
                "RecvMonitor":{
                    "Start":"2020-11-30T10:04:05.3Z",
                    "Bytes":0,
                    "Samples":1045790,
                    "InstRate":0,
                    "CurRate":0,
                    "AvgRate":0,
                    "PeakRate":0,
                    "BytesRem":0,
                    "Duration":863087180000000,
                    "Idle":863087180000000,
                    "TimeRem":0,
                    "Progress":0,
                    "Active":true
                },
                "Channels":[
                    {
                        "ID":0,
                        "SendQueueCapacity":10,
                        "SendQueueSize":0,
                        "Priority":1,
                        "RecentlySent":0
                    },
                    {
                        "ID":32,
                        "SendQueueCapacity":100,
                        "SendQueueSize":0,
                        "Priority":5,
                        "RecentlySent":2235
                    },
                    ...
                ]
            },
            "remote_ip":"13.212.86.71"
        },
        ...
    ]
}

node_datadir

Returns the data directory of current node.

Parameters

none

Returns

String - data directory of current node.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "node_datadir",
    "params": [],
    "id": 1
}'

// Result
{
    "jsonrpc":"2.0",
    "id":1,
    "result":"/home/.kardia"
}

kai_blockNumber

Returns the number of the most recent block.

Parameters

none

Returns

QUANTITY - integer of the current block number the client is on.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_blockNumber",
    "params": [],
    "id": 1
}'

// Result
{
    "jsonrpc":"2.0",
    "id":1,
    "result":20500
}

kai_getBlockByHash

Returns information of a block by hash.

Parameters
  1. DATA, 32 Bytes - Hash of a block.
params: [
   '0xe376ec64341771606e5546b4ca35a1a6b75ee3d5145a99d05071826d1527331'
]
Returns

Object - A block object, or null when no block was found:

  • hash: DATA, 32 Bytes - hash of the block. null when its pending block.
  • height: QUANTITY - the block height. null when its pending block.
  • lastBlock: DATA - the last block ID. null when its pending block.
  • commitHash: DATA - hash of last commit. null when its pending block.
  • time: QUANTITY - the unix timestamp for when the block was collated.
  • numTxs: QUANTITY - the number of transactions in the block.
  • gasLimit: QUANTITY - the maximum gas allowed in this block.
  • gasUsed: QUANTITY - the total used gas by all transactions in this block.
  • rewards: QUANTITY - the reward for chosen proposer for finalizing this block.
  • proposerAddress: DATA, 20 Bytes - address of the chosen proposer who finalizing this block.
  • dataHash: DATA, 32 Bytes - hash of block data.
  • receiptsRoot: DATA, 32 Bytes - hash of the transactions.
  • logsBloom: DATA, 256 Bytes - the bloom filter for the logs of the block. null when its pending block.
  • validatorsHash: DATA, 32 Bytes - hash of current validators set.
  • nextValidatorHash: DATA, 32 Bytes - hash of next validators set.
  • consensusHash: DATA, 32 Bytes - hash of the block consensus.
  • appHash: DATA, 32 Bytes - hash of current state.
  • evidenceHash: DATA, 32 Bytes - hash evidences list.
  • txs: Array - Array of transaction objects in this block.
  • receipts: Array - Array of receipt objects in this block.
Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_getBlockByHash",
    "params": [
        "0xd2f1676793dd04d21d8839db810b074376c2f492e0b97ab03135288403016ae5"
    ],
    "id": 1
}'

// Result
{
    "jsonrpc":"2.0",
    "id":1,
    "result":{
        "hash":"0xd2f1676793dd04d21d8839db810b074376c2f492e0b97ab03135288403016ae5",
        "height":468106,
        "lastBlock":"0xf93ed1ef25e65dffe69b38713b65c78fde393aa7eb4d49d12e7bcf92c4a4bc1f",
        "commitHash":"0x798f0312a9db18c52f9a7961cd5cf8b2ecca1fdf8176f8f93b08bf243d3a5041",
        "time":"2020-12-10T10:12:55.594643535Z",
        "numTxs":0,
        "gasLimit":150000000,
        "gasUsed":0,
        "rewards":"15021079522649060320",
        "proposerAddress":"0x2923391187B3cc2c0453501D2c6b793982DB66A3",
        "dataHash":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
        "receiptsRoot":"",
        "logsBloom":"",
        "validatorHash":"0xa0d049f496064b5c57fb7d49f7bcca1d4718a549b42b840b3a9baf533636cb0f",
        "nextValidatorHash":"0xa0d049f496064b5c57fb7d49f7bcca1d4718a549b42b840b3a9baf533636cb0f",
        "consensusHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
        "appHash":"0x2ff200f591e893f288414abae2c7b1322b686de8b76f6d30e02bac10696ac449",
        "evidenceHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
        "txs":[],
        "receipts":[]
    }
}

kai_getBlockByNumber

Returns information about a block by block number.

Parameters
  1. QUANTITY|TAG - integer of a block number, or the string "earliest", "latest" or "pending", as in the default block parameter.
params: [
    468106 // block number 436
]
Returns

See kai_getBlockByHash

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_getBlockByNumber",
    "params": [
        468106
    ],
    "id": 1
}'

Result see kai_getBlockByHash


kai_getBlockHeaderByNumber

Returns header fields of a block by block number.

Parameters
  1. QUANTITY|TAG - integer of a block number, or the string "earliest", "latest" or "pending", as in the default block parameter.
params: [
    468106 // block number 436
]
Returns

See kai_getBlockByHash

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_getBlockHeaderByNumber",
    "params": [
        468106
    ],
    "id": 1
}'

Result see kai_getBlockByHash


kai_getBlockHeaderByHash

Returns header fields of a block by block hash.

Parameters
  1. DATA, 32 Bytes - Hash of a block.
params: [
    "0xe376ec64341771606e5546b4ca35a1a6b75ee3d5145a99d05071826d1527331"
]
Returns

See kai_getBlockByHash

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_getBlockHeaderByHash",
    "params": [
        "0xe376ec64341771606e5546b4ca35a1a6b75ee3d5145a99d05071826d1527331"
    ],
    "id": 1
}'

Result see kai_getBlockByHash


kai_kardiaCall

Make a static call (not creating a transaction) for interacting with blockchain.

Parameters
  1. Object - Needed parameters to make a call.
"params": [
    {
        "data": "0x1904bb2e000000000000000000000000FBD5e2aFB7C0a7862b06964e29E676bf02183256",
        "from": "0x",
        "gas": 900000,
        "gasPrice": 1,
        "to": "0x0000000000000000000000000000000000001337",
        "value": 0
    },
    "latest"
],
Returns

DATA - the call result.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_kardiaCall",
    "params": [
        {
            "data": "0x1904bb2e000000000000000000000000FBD5e2aFB7C0a7862b06964e29E676bf02183256",
            "from": "0x",
            "gas": 900000,
            "gasPrice": 1,
            "to": "0x0000000000000000000000000000000000001337",
            "value": 0
        },
        "latest"
    ],
    "id": 1
}'

// Result
{
    "jsonrpc": "2.0",
    "id": 1,
    "error": {
        "code": -32000,
        "message": "execution reverted"
    }
}

kai_estimateGas

Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain. Note that the estimate may be significantly more than the amount of gas actually used by the transaction, for a variety of reasons including EVM mechanics and node performance.

Parameters

See kai_kardiaCall parameters, expect that all properties are optional. If no gas limit is specified geth uses the block gas limit from the pending block as an upper bound. As a result the returned estimate might not be enough to executed the call/transaction when the amount of gas is higher than the pending block gas limit.

Returns

QUANTITY - the amount of gas used.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_estimateGas",
    "params": [
        {
            "data": "0x1904bb2e000000000000000000000000FBD5e2aFB7C0a7862b06964e29E676bf02183256",
            "from": "0x",
            "gas": 900000,
            "gasPrice": 1,
            "to": "0x0000000000000000000000000000000000001337",
            "value": 0
        },
        "latest"
    ],
    "id": 1
}'

// Result
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": 32028
}

kai_newFilter

Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call kai_getFilterChanges.

A note on specifying topic filters: Topics are order-dependent. A transaction with a log with topics [A, B] will be matched by the following topic filters:

  • [] “anything”
  • [A] “A in first position (and anything after)”
  • [null, B] “anything in first position AND B in second position (and anything after)”
  • [A, B] “A in first position AND B in second position (and anything after)”
  • [[A, B], [A, B]] “(A OR B) in first position AND (A OR B) in second position (and anything after)”
Parameters
  1. Object - The filter options:
  • fromBlock: QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
  • toBlock: QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
  • address: DATA|Array, 20 Bytes - (optional) Contract address, or a list of addresses from which logs should originate.
  • topics: Array of DATA, - (optional) Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with “or” options.
"params": [
    "fromBlock": 1,
    "toBlock": 2,
    "address": "0x8888f1f195afa192cfee860698584c030f4c9db1",
    "topics": ["0xb0d234274aef7a61aa5a2eb44c23881ebf46a068cccbd413c978bcbd555fe17f"]
],
Returns

QUANTITY - A filter id.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \\
--header "Content-Type: application/json" \\
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_newFilter",
    "params": [
        {
            "fromBlock": 1,
            "toBlock": 2,
            "address": "0x8888f1f195afa192cfee860698584c030f4c9db1",
            "topics": [
                "0xb0d234274aef7a61aa5a2eb44c23881ebf46a068cccbd413c978bcbd555fe17f"
            ]
        }
    ],
    "id": 1
}

// Response
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": "0xd4d6cab8e6de13d09eec61c681f3039f"
}

kai_newBlockFilter

Creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call kai_getFilterChanges.

Parameters

None

Returns

QUANTITY - A filter id.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \\
--header "Content-Type: application/json" \\
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_newBlockFilter",
    "params": [],
    "id": 1
}

// Response
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": "0xd4d6cab8e6de13d09eec61c681f3039f"
}

kai_uninstallFilter

Uninstalls a filter with given id. Should always be called when watch is no longer needed. Additonally Filters timeout when they aren’t requested with kai_getFilterChanges for a period of time.

Parameters
  1. QUANTITY - A filter id.
"params": [
    "0xd4d6cab8e6de13d09eec61c681f3039f"
],
Returns

Boolean - true if the filter was successfully uninstalled, otherwise false.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \\
--header "Content-Type: application/json" \\
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_uninstallFilter",
    "params": [
        "0xd4d6cab8e6de13d09eec61c681f3039f"
    ],
    "id": 1
}

// Response
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": true
}

kai_getFilterChanges

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

Parameters
  1. QUANTITY - the filter id.
"params": [
    "0xd4d6cab8e6de13d09eec61c681f3039f"
],
Returns

kai_getFilterChanges Array - Array of log objects, or an empty array if nothing has changed since last poll.

  • For filters created with kai_newBlockFilter the return are block hashes (DATA, 32 Bytes), e.g. ["0x3454645634534..."].
  • For filters created with kai_newFilter logs are objects with following params:
    • logIndex: QUANTITY - integer of the log index position in the block. null when its pending log.
    • transactionIndex: QUANTITY - integer of the transactions index position log was created from. null when its pending log.
    • transactionHash: DATA, 32 Bytes - hash of the transactions this log was created from. null when its pending log.
    • blockHash: DATA, 32 Bytes - hash of the block where this log was in. null when its pending. null when its pending log.
    • blockNumber: QUANTITY - the block number where this log was in. null when its pending. null when its pending log.
    • address: DATA, 20 Bytes - address from which this log originated.
    • data: DATA - contains one or more 32 Bytes non-indexed arguments of the log.
    • topics: Array of DATA - Array of 0 to 4 32 Bytes DATA of indexed log arguments. (In solidity: The first topic is the hash of the signature of the event (e.g. Deposit(address,bytes32,uint256)), except you declared the event with the anonymous specifier.)
    • removed: TAG - true when the log was removed, due to a chain reorganization. false if its a valid log.
Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \\
--header "Content-Type: application/json" \\
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_getFilterChanges",
    "params": [
        "0xd4d6cab8e6de13d09eec61c681f3039f"
    ],
    "id": 1
}

// Response
{
    "jsonrpc": "2.0",
    "id": 1,
    "result":  [
        {
            "address": "0xf35a869a0f96dfd6bce6d57ecf9ef5a883b59c61",
            "topics": [
                "0xb0d234274aef7a61aa5a2eb44c23881ebf46a068cccbd413c978bcbd555fe17f"
            ],
            "data": "0x000000000000000000000000c1fe56e3f58d3244f606306611a5d10c8333f1f600000000000000000000000000000000000000000000054b40b1f852bda00000",
            "blockHeight": 5,
            "transactionHash": "0x8d8d38bf099ec1a3b5bcc4dbc091dc62020236023863f7afb6f852a9d4828a0b",
            "transactionIndex": 0,
            "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
            "logIndex": 1,
            "removed": false
        }, {
            ...
        }]
}

kai_getFilterLogs

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

Parameters
  1. QUANTITY - The filter id.
"params": [
    "0xd4d6cab8e6de13d09eec61c681f3039f"
],
Returns

See kai_getFilterChanges

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \\
--header "Content-Type: application/json" \\
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_getFilterLogs",
    "params": [
        "0xd4d6cab8e6de13d09eec61c681f3039f"
    ],
    "id": 1
}

Result see kai_getFilterChanges


kai_getLogs

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

Parameters
  1. Object - The filter options:
  • fromBlock: QUANTITY|TAG - (optional, default: latest) Integer block number, or "latest" for the last mined block or pending, earliest for not yet mined transactions.
  • toBlock: QUANTITY|TAG - (optional, default: latest) Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
  • address: DATA|Array, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.
  • topics: Array of DATA, - (optional) Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with “or” options.
  • blockhash: DATA, 32 Bytes - (optional) block hash which restricts the logs returned to the single block with the 32-byte hash blockHash. Using blockHash is equivalent to fromBlock = toBlock = the block number with hash blockHash. If blockHash is present in in the filter criteria, then neither fromBlock nor toBlock are allowed.
Returns

See kai_getFilterChanges

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \\
--header "Content-Type: application/json" \\
--data-raw '{
    "jsonrpc": "2.0",
        "method": "kai_newFilter",
        "params": [
            {
                "fromBlock": 544,
                "toBlock": 585,
                "blockHash": "0xb46f7cda96e4ee6e042f726f243ac9d8bd88f3fff5830b8f9bcfcb26df65accf",
                "topics": [
                    "0xb0d234274aef7a61aa5a2eb44c23881ebf46a068cccbd413c978bcbd555fe17f"
                ]
            }
        ],
        "id": 1
}

Result see kai_getFilterChanges


kai_validator

Returns validator info by their address.

Parameters
  1. DATA, 20 bytes - address of a validator.
  2. Boolean - true will return a detailed list of delegators who delegate to this validator, otherwise false.
params: [
    "0xfbd5e2afb7c0a7862b06964e29e676bf02183256",
    true
]
Returns

Object - The details information of validator. null if address is not a validator.

  • name: DATA - name of this validator.
  • address: DATA, 20 bytes - address of this validator.
  • stakedAmount: DATA - total staked amount (in HYDRO) of this validator and all of his delegators.
  • commissionRate: DATA - commission rate of this validator, multiplied by 10**18.
  • totalDelegators: QUANTITY - number of delegators who delegated to this validator.
  • maxRate: DATA - max commission rate of this validator, multiplied by 10**18.
  • maxChangeRate: DATA - max commission rate of this validator per one time change, multiplied by 10**18.
  • jailed: Boolean - is true if this validator is jailed, otherwise is false.
  • minSelfDelegation: DATA - minimum stake amount (in HYDRO) that a validator is required to register.
  • delegationShares: DATA - total shares of delegators.
  • accumulatedCommission: DATA - current accumulated commission (in HYDRO) for delegators.
  • ubdEntryCount: DATA - information of an unbonding entry.
  • updateTime: DATA - latest updated time.
  • status: QUANTITY - current status of this validator, included Unbonding, Unbonded, Bonded.
  • unbondingTime: DATA - minimum waiting time required to withdraw unbonding amount.
  • unbondingHeight: DATA - minimum block height required to withdraw unbonding amount.
  • delegators: Array - list of delegators' information.
Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_validator",
    "params": [
        "0xfbd5e2afb7c0a7862b06964e29e676bf02183256",
        true
    ],
    "id": 1
}'

// Result
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "name": "val1",
    "address": "0xFBD5e2aFB7C0a7862b06964e29E676bf02183256",
    "stakedAmount": "15000000000000000000000000",
    "commissionRate": "100000000000000000",
    "totalDelegators": 1,
    "maxRate": "250000000000000000",
    "maxChangeRate": "50000000000000000",
    "jailed": false,
    "minSelfDelegation": "10000000000000000000000000",
    "delegationShares": "1000000000000000000",
    "accumulatedCommission": "10469927972264942290634",
    "ubdEntryCount": "0",
    "updateTime": "1605524400",
    "status": 2,
    "unbondingTime": "0",
    "unbondingHeight": "0",
    "delegators": [
      {
        "address": "0xFBD5e2aFB7C0a7862b06964e29E676bf02183256",
        "stakedAmount": "15000000000000000000000000",
        "reward": "94229351750384475000000"
      }
    ]
  }
}

kai_validators

Returns detailed information of all validators.

Parameters
  1. Boolean - true will return a detailed list of delegators who delegate to this validator, otherwise false.
Returns

See kai_validator

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_validators",
    "params": [
        true
    ],
    "id": 1
}'

// Result
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "name": "val1",
      "address": "0xFBD5e2aFB7C0a7862b06964e29E676bf02183256",
      "stakedAmount": "15000000000000000000000000",
      "commissionRate": "100000000000000000",
      "totalDelegators": 1,
      "maxRate": "250000000000000000",
      "maxChangeRate": "50000000000000000",
      "jailed": false,
      "minSelfDelegation": "10000000000000000000000000",
      "delegationShares": "1000000000000000000",
      "accumulatedCommission": "10469927972264942290634",
      "ubdEntryCount": "0",
      "updateTime": "1605524400",
      "status": 2,
      "unbondingTime": "0",
      "unbondingHeight": "0",
      "delegators": [
        {
          "address": "0xFBD5e2aFB7C0a7862b06964e29E676bf02183256",
          "stakedAmount": "15000000000000000000000000",
          "reward": "94229351750384475000000"
        }
      ]
    },
    ...
  ]
}

kai_gasPrice

Returns the current gas price in HYDRO.

Parameters
Returns

String - string of the current gas price in HYDRO.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_gasPrice",
    "params": [],
    "id": 1
}'

// Result
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": "1000000000"
}

kai_getCommit

Returns the validators' commits of a block by its height.

Parameters
  1. QUANTITY|TAG - integer of a block height, or the string "earliest", "latest" or "pending", as in the default block parameter.
params: [
    "latest"
]
Returns

Object - A block commits object, or null when no commit with this block was found.

  • block_id: Object - blockID of this block
    • hash: DATA, 32 Bytes - hash of this block
    • parts: Object - block parts details of this block
      • total: QUANTITY - total number of block parts belong to this block
      • hash: DATA, 32 Bytes - hash of block parts
  • signatures: Array - list of validators' signatures
    • block_id_flag: QUANTITY -
    • validator_address: DATA, 20 bytes - address of this validator
    • timestamp: DATA - timestamp when this validator commit for this block
    • signature: DATA - hex form of the signature for validating
  • height: QUANTITY - block height
  • round: QUANTITY - the final round of which this block is finalized
Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_getCommit",
    "params": [5],
    "id": 1
}'

// Result
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "block_id": {
      "hash": "0x7910b433e6f4f60788552efae1f61c59e09cf20d2f69d70217b7cd1e9bc11255",
      "parts": {
        "total": 1,
        "hash": "0xc255dd43d2495e6a9e87375d82afc715f0cb03de65e81004c7bf4b7494e2b9b4"
      }
    },
    "signatures": [
      {
        "block_id_flag": 2,
        "validator_address": "0x7cefc13b6e2aedeedfb7cb6c32457240746baee5",
        "timestamp": "2021-05-14T11:19:35.686463493Z",
        "signature": "oIpicG3JSTWeDq3e0AFytC3TtrMkoErex3cCYMeMzq19aA0+aZIUXKlgajn9cAEnb+8lnWe177g2M1PAZPhw+QA="
      },
      {
        "block_id_flag": 2,
        "validator_address": "0xc1fe56e3f58d3244f606306611a5d10c8333f1f6",
        "timestamp": "2021-05-14T11:19:35.748338171Z",
        "signature": "/2K0OodTovT0VgC90B8tTTwixzE+io4PJhav/Sca2YVKs03BzqR/36WurMRD70biEeTwAG/bAZIcojCVxhft+AA="
      }
    ],
    "height": 5,
    "round": 1
  }
}

kai_getValidatorSet

Returns the validators set of a block by its height.

Parameters
  1. QUANTITY|TAG - integer of a block height, or the string "earliest", "latest" or "pending", as in the default block parameter.
params: [
    "latest"
]
Returns

Object - A block commits object, or null when no commit with this block was found.

  • validators: Array of Object - details of the validators in set of this block
    • address: DATA, 20 bytes - address of this validator.
    • votingPower: QUANTITY - voting power of validator at this block
    • proposerPriority: QUANTITY - a number which indicates which validator will propose the next block.
  • proposer: Object - details of the proposer of this block
Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_getValidatorSet",
    "params": [5],
    "id": 1
}'

// Result
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "validators": [
      {
        "address": "0x7cefc13b6e2aedeedfb7cb6c32457240746baee5",
        "votingPower": 1250000000000000,
        "proposerPriority": -1250000000000000
      },
      {
        "address": "0xc1fe56e3f58d3244f606306611a5d10c8333f1f6",
        "votingPower": 1250000000000000,
        "proposerPriority": -1250000000000000
      },
      {
        "address": "0xff3dac4f04ddbd24de5d6039f90596f0a8bb08fd",
        "votingPower": 1250000000000000,
        "proposerPriority": 2500000000000000
      }
    ],
    "proposer": {
      "address": "0xc1fe56e3f58d3244f606306611a5d10c8333f1f6",
      "votingPower": 1250000000000000,
      "proposerPriority": -1250000000000000
    }
  }
}

kai_getProof

Returns the merkle-proof for a given address and optionally some storage keys.

Parameters
  1. DATA, 20 Bytes - the address we want to proof
  2. Array - storage keys of this address
  3. QUANTITY|TAG - integer of a block height, or the string "earliest", "latest" or "pending", as in the default block parameter.
"params": [
    "0x0000000000000000000000000000000000001337",
    [
        "0x0000000000000000000000000000000000000000000000000000000000000001"
    ],
    "latest"
]
Returns

Object - An account proof details, including values of some storage keys as requested

  • address: ``DATA`, 32 Bytes -
  • accountProof: Array - Array of rlp-serialized MerkleTree-Nodes, starting with the stateRoot-Node, following the path of the SHA3 (address) as key
  • balance: QUANTITY - the balance of the account. See account_balance
  • codeHash: DATA, 32 Bytes - hash of the code of the account. For a simple Account without code it will return "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
  • nonce: QUANTITY - nonce of the account. See account_nonce
  • storageHash: DATA, 32 Bytes - SHA3 of the StorageRoot. All storage will deliver a MerkleProof starting with this rootHash
  • storageProof: Array of Object - Array of storage-entries as requested. Each entry is a object with these properties:
    • key: QUANTITY - the requested storage key
    • value: QUANTITY, - the storage value
    • proof: ARRAY - Array of rlp-serialized MerkleTree-Nodes, starting with the storageHash-Node, following the path of the SHA3 (key) as path
Example
// Request
curl --location --request GET 'https://rpc.kardiachain.io/' \
--header 'Content-Type: application/json' \
--data-raw '{
  "jsonrpc": "2.0",
  "method": "kai_getProof",
  "params": [
    "0x0000000000000000000000000000000000001337",
    [
      "0x0000000000000000000000000000000000000000000000000000000000000001"
    ],
    "latest"
  ],
  "id": 1
}'

// Result
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "address": "0x0000000000000000000000000000000000001337",
    "accountProof": [
      "0xf90211a0433f65bef68a952a472bb031b4fe2d7d76dd41ceb629085bf60ccac09967cd7da063b083ad58fe9cadcf4c2afaf40330b0ba663bd2796f42340c14ed78830b5b6ea0bba413a8a5c90680da884ad08dcf23c7fe92eadb6fcd88d89c343f01305e300ea01ecc781cce5c63cb2bbb1360e182a9c5c83878eeb48bca4c19ba47ca2e837e9ea02412181790f7eb32b4b02a05d9dfb79863bc6f86925eab0f5f8d5405eff6e56da041aa5219a66419dfe37737fade86cdbe67cc1d0cdbb709559d7d03dd82d0a90ea03fdb6b9266301b77d23d4b471bf0a479b93e03d09cf27fe2efd7327a8f9f6e95a0c4b012ae402df58eed5d83c5fb7f7ef246a5dd5fdc91f710c84a0148f8e0060aa04957b74e501a4976725fd74978abab861b6fb18ddd32a7face9ad5af9cee380fa072dc1d30cb07a5cfe895cc33f3ecf1d75944846e29584d965ba871c658fc3cdda09eda28e41705689309a6063652d5f45d8db423527b984d893088f96d7a72f09ca0a03271578f465fe2d869424932e058370760b13747b19e52eb860ce501c58ceda07728c1069e94794d73c959aca8fdfc3a0d6ef19efe6f14633d0126094c44c08aa021ccae8e87cbab291593056f55306ec22d9edbd990b2fde38859126dc339b6aba0e35502efe94457ef664cbae18c9e7be2bc04687bd748d0666a83535d90f30d97a02b96bee24c66df0c037300b806b097a4bab6628103899184d74a6c52473cc07c80",
      "0xf901f1a05c3135cf22d12717397cb97886d623e6cb57f5a15cd0f1f01b807b73fcdecfcaa0a209c55157bf4cc94d082fe2b7dea09043aff19a006e1b10695cca7405d4c0baa0702d169550c8a1bc58afc9eba914eede14025ec74aa8bfe43feadb8d9285aef1a0290e09533be7e9c408f88b7958a91aa678fe4db592d95ed50d780947d3830857a0f0258cd99a8bd803296ca9dcccaa68069008704204abdfe5caa656cfa2da59dea0eb228408157b9fbb42c9aca9781af40c28e990e439b37c7993a9fe25a48b2d8680a0a8a5924f6f6c27e172fb909df1234ef9acb6e49ab276896b1f80a6429f2221b1a036b8756b367e0c85d4383a60cddef6cd1a40ed1e8f126804c48b33fc767f9877a0151120aa2f2a09c7d213d25300ebef5d877cf94c414950b02151e877d395bcc3a0234f4ab9c133ba15c7fa880a2f8bc7140bbaba2fceac655e54537235be0a38d4a0daecfa41d7ecfb10a796d09b65dd88d03270b0510e08ca516fe5e8aa3388b4e1a0d4c21f6791c04a49dcda92ec1d8fe7db4956e24cc1145a27efaf7d988f201f5ba0cf06f3b18953195fdaa01d8a6553d784e67efe5e5ab0d66aad51b46319ec64f9a069be99df13831ef4550647740405fc1e9f05877744d9a8fa97ab69b1dba49f3fa00a08ab0c4adda9f3ede4f9eb43f72edf92cb14bb9a63cb9a61b51dcd71671b2580",
      "0xf891a05673006d9ac141a50ae5cad1f5fd36016383ac1c6bf60b598ee310e1e0886a8580a065ff8b75cc9d951fc758757a0b31fd3e941a897cc1eb4a959b46b1adcc8c2d878080808080808080a06afecf8145c545c9285489a53028f426f0f8b203b2060cfe94544890281a65c8808080a08b3345d33a1e0c49070b28d7f7dec4c21b03707b475080b969eb8fe0b34d872380",
      "0xf8719f36533211b5c8c15a7361280857dba650d7a6c1f4782ce3b107237c19a54914b84ff84d07890b9a6b8b0b5d5fed3fa04f1b41a596c0e4bfffbd315efdb567cb31aae37420444f3803baefe57d58d230a033918cc08463654f3e8b71f958769b1cc2bbf1673835126963bfe41fbd1f8bbe"
    ],
    "balance": "0x0",
    "codeHash": "0x33918cc08463654f3e8b71f958769b1cc2bbf1673835126963bfe41fbd1f8bbe",
    "nonce": "0x7",
    "storageHash": "0x4f1b41a596c0e4bfffbd315efdb567cb31aae37420444f3803baefe57d58d230",
    "storageProof": [
      {
        "key": "0x0000000000000000000000000000000000000000000000000000000000000001",
        "value": "0x2540be400",
        "proof": [
          "0xf901f1a045cc003eb8c76ce873f640000d6ed1ebb264fd1c6cdf8f74602e2afe6e6504b7a07dedec64117d65ba6f79dc0ab220046b8ee3bf7ecb0628ff83ae12c0e0e64bdba07a4c592fa7de5ccc9936ed18e039b39a346995a935f99d23d13dba1cc9ae65bea0b83265bab63de4a813c575bb37ce9663f68f1127e21ba764c9c5adb3f4a57ca9a0aa7e1ebec86dce57f74ed419d3605e7aa5088289f1694e8c6b532029be3a5f4ca0b5e95c5e883542f408efa4f97af50316b54feb0e1750ded5c4dd0cf0756c7ef0a08be881bc09bbd84a922bd77cc5ca8710bb7e9cbaf7d5fd6f2a1aba3db8bd94c980a071812be7a194b4ee4c32e0a4e1dab325701bb4ea85222de0f13e59394d9a60ada0ac287dadb9f2070a53b759f99b44364c04a1113d4a619017725242ea47d6d49ba030984f929f0bdfdb9e13f5a33faa6562520a4d22623e6e49f9df48aad7bad0bfa060ee3fdd43ab949a64bedab2c6ff5fc7988b6703d87af3f8f04ec1debe96887aa01ac2be79bfeba88a695bc3ba7318321a02747493de4f4bc9951b15e499375e0fa03726e57c74dc7952ef01c7f26250e5156aef517a0f00546a255960be5f245242a0709ff9c335dcd69a6236d9b28a323d251ca6a1423cd4b54fd59c9787a06cc39ea08c48ea92cdc5d892fc897ddfff55e52f8e1b6ebfb9cf31f38c1a96b9427fc5ac80",
          "0xf89180a06579ec76ec26eb9a3aae2a7153b653414079e81c33996ae330204a9f26470639a00c20a519fbc246729042576a5e11ae0d828cf2c7434f6b9d51c60c462512815180808080a0ab2432609effc68e3eac34e4871baa1fc3dd58fcc3f3efb8593e24f3b3e5793a808080a0d54cd94a2c7763ee6b31e845ae761a934b4b381e52c5adbc888e5b6a31b3315d8080808080",
          "0xe8a0200e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6868502540be400"
        ]
      }
    ]
  }
}

tx_sendRawTransaction

Creates new message call transaction, or a contract creation for signed transactions.

Parameters
  1. DATA, The signed transaction data.
params: ["0xf8908001832dc6c09400000000000000000000000000000000000013378c01f04ef12cb04cf158000000a45c19a95c000000000000000000000000c1fe56e3f58d3244f606306611a5d10c8333f1f61ba09cf19e5f53a27d1ceeb5fdd9f77fab629f9b233db4f4740ecdd0c06c6d56e72ca043597f65c741779728be8e4a96f0518fee73c24228304fd06f027c42cc33c3df"]
Returns

DATA, 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available, or error returned.

Use tx_getTransactionReceipt to get the contract address, after the transaction was mined, when you created a contract.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "tx_sendRawTransaction",
    "params": [
        "0xf8908001832dc6c09400000000000000000000000000000000000013378c01f04ef12cb04cf158000000a45c19a95c000000000000000000000000c1fe56e3f58d3244f606306611a5d10c8333f1f61ba09cf19e5f53a27d1ceeb5fdd9f77fab629f9b233db4f4740ecdd0c06c6d56e72ca043597f65c741779728be8e4a96f0518fee73c24228304fd06f027c42cc33c3df"
    ],
    "id": 1
}'

// Result
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0xe547ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}

tx_pendingTransactions

Returns the transactions that are in the transaction pool and have a from address that is one of the accounts this node manages.

Parameters

none

Returns

Array - The list of all pending transactions.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "tx_pendingTransactions",
    "params": [],
    "id": 1
}'

// Result
{
  "id":1,
  "jsonrpc":"2.0",
  "result": [{Pending transactions list}]
}

tx_getTransaction

Returns the information about a transaction requested by transaction hash.

Parameters
  1. DATA, 32 Bytes - hash of a transaction.
params: [
   "0xf5ade9d9d30f5da689443524175b2c4285ad8bd8e93c9b0c1161bb21b314e101"
]
Returns

Object - A transaction object, or null when no transaction with this hash was found.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "tx_getTransaction",
    "params": [
        "0xf5ade9d9d30f5da689443524175b2c4285ad8bd8e93c9b0c1161bb21b314e101"
    ],
    "id": 1
}'

// Result
{
    "jsonrpc":"2.0",
    "id":1,
    "result":{
        "blockHash":"0x4f37589e67772830773c32f543e9334c3c9cf17c317c297a68739e5f192f855a",
        "blockNumber":469321,
        "time":"2020-12-10T11:42:36.106211438Z",
        "from":"0xE38a833DF97e01838C7fb09Ce1eC1ea27C5FB6e8",
        "gas":3000000,
        "gasPrice":1,
        "hash":"0xf5ade9d9d30f5da689443524175b2c4285ad8bd8e93c9b0c1161bb21b314e101",
        "input":"0x5c19a95c000000000000000000000000b7cb37d1d77a15a524ee62f8ef4a7fb7747c2e79",
        "nonce":15,
        "to":"0x0000000000000000000000000000000000001337",
        "transactionIndex":0,
        "value":"100000000000000000000000",
        "logsBloom":[...],
        "status":0
    }
}

tx_getTransactionReceipt

Returns the receipt of a transaction by transaction hash.

Note That the receipt is not available for pending transactions.

Parameters
  1. DATA, 32 Bytes - hash of a transaction.
params: [
   '0xf5ade9d9d30f5da689443524175b2c4285ad8bd8e93c9b0c1161bb21b314e101'
]
Returns

Object - A transaction receipt object, or null when no receipt was found.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "tx_getTransactionReceipt",
    "params": [
        "0xf5ade9d9d30f5da689443524175b2c4285ad8bd8e93c9b0c1161bb21b314e101"
    ],
    "id": 1
}'

// Result
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "blockHash": "0x4f37589e67772830773c32f543e9334c3c9cf17c317c297a68739e5f192f855a",
        "blockHeight": 469321,
        "transactionHash": "0xf5ade9d9d30f5da689443524175b2c4285ad8bd8e93c9b0c1161bb21b314e101",
        "transactionIndex": 0,
        "from": "0xE38a833DF97e01838C7fb09Ce1eC1ea27C5FB6e8",
        "to": "0x0000000000000000000000000000000000001337",
        "gasUsed": 308439,
        "cumulativeGasUsed": 308439,
        "contractAddress": "0x",
        "logs": [
            {
                "address": "0x0000000000000000000000000000000000001337",
                "topics": [
                    "0x510b11bb3f3c799b11307c01ab7db0d335683ef5b2da98f7697de744f465eacc"
                ],
                "data": "000000000000000000000000b7cb37d1d77a15a524ee62f8ef4a7fb7747c2e79000000000000000000000000e38a833df97e01838c7fb09ce1ec1ea27c5fb6e800000000000000000000000000000000000000000000152d02c7e14af6800000",
                "blockHeight": 469321,
                "transactionHash": "0xf5ade9d9d30f5da689443524175b2c4285ad8bd8e93c9b0c1161bb21b314e101",
                "transactionIndex": 0,
                "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "logIndex": 6,
                "removed": false
            }
        ],
        "logsBloom": [...],
        "root": "0x",
        "status": 1
    }
}

account_balance

Returns the balance of the account of given address.

Parameters
  1. DATA, 20 Bytes - address to check for balance.
  2. DATA - hash of the block. (optional)
  3. QUANTITY - the block height. (optional)
"params": [
    "0xf64C35a3d5340B8493cE4CD988B3c1e890B2bD68",
    "latest"
],

Note: The node will use the balance at the block retrieved by the hash and/or height. If both are not given, the current block will be used.

Returns

QUANTITY - integer of the current balance.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "account_balance",
    "params": [
        "0xf64C35a3d5340B8493cE4CD988B3c1e890B2bD68",
        "latest"
    ],
    "id": 1
}'

// Result
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": "998999999999999999999979000"
}

account_nonce

Return the address's nonce.

Parameters
  1. DATA, 20 Bytes - address to check for balance.
params: [
   "0xf64C35a3d5340B8493cE4CD988B3c1e890B2bD68",
]
Returns

QUANTITY - Return the address's nonce.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "account_nonce",
    "params": [
      "0xf64C35a3d5340B8493cE4CD988B3c1e890B2bD68"
    ],
    "id": 1
}'

// Result
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": 3390
}

account_nonceAtHeight

Return the address's nonce at a specific block height.

Parameters
  1. DATA, 20 Bytes - address to check for balance.
  2. QUANTITY|TAG - integer of a block number, or the string "earliest", "latest" or "pending", as in the default block parameter.
params: [
    "0xf64C35a3d5340B8493cE4CD988B3c1e890B2bD68",
    "latest"
]
Returns

QUANTITY - Return the address's nonce at this specific block height.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "account_nonceAtHeight",
    "params": [
      "0xf64C35a3d5340B8493cE4CD988B3c1e890B2bD68",
      "latest"
    ],
    "id": 1
}'

// Result
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": 3390
}

account_getCode

Returns code at a given address.

Parameters
  1. DATA, 20 Bytes - address.
  2. QUANTITY|TAG - integer of a block number, or the string "earliest", "latest" or "pending", as in the default block parameter.
params: [
    "0x0000000000000000000000000000000000001337",
    "latest"
]
Returns

DATA - the code from the given address.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "account_getCode",
    "params": [
        "0x0000000000000000000000000000000000001337",
        "latest"
    ],
    "id": 1
}'

// Result
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": "0x6080604052600436106102935760003560e01c80635e5a3cb61161015a578063c4e41b22116100c1578063e0a8ed521161007a578063e0a8ed52146..."
}

account_getStorageAt

Returns the value from a storage position at a given address.

Parameters
  1. DATA, 20 Bytes - address of the storage.
  2. QUANTITY - integer of the position in the storage.
  3. QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the default block parameter
"params": [
    "0x0000000000000000000000000000000000001337",
    "0x1",
    "latest"
],
Returns

DATA - the code from the given address.

Example
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "account_getStorageAt", 
    "params": [
        "0x0000000000000000000000000000000000001337",
        "0x1",
        "latest"
    ],
    "id": 1
}'

// Result
{
    "jsonrpc":"2.0",
    "id":1,
    "result":"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"
}

Websocket

Introduction

KardiaChain WebSocket endpoint provides support for Pub/Sub API as well as JSON-RPC filter support. Additionally, the regular KardiaChain JSON-RPC API is also supported over a WebSocket connection and documented in the 'EXAMPLE' portion for each 'KardiaChain JSON-RPC' call.

All examples in this reference section uses wscat, but will work with any tool that supports the WebSocket protocol. Some tools you can use for making these requests.

wscat

Advanced Rest Client

Websocket subscription requests should include the WS host in the WebSocket API url.

wscat -c wss://ws.kardiachain.io

kai_subscribe

Creates a new subscription over particular events. The node will return a subscription id. For each event that matches the subscription a notification with relevant data is sent together with the subscription id.

REQUEST PARAMS

SUBSCRIPTION TYPE NAME [required]

  • newHeads - Subscribing to this, fires a notification each time a new header is appended to the chain, including chain reorganizations. In case of a chain reorganization the subscription will emit all new headers for the new chain. Therefore the subscription can emit multiple headers on the same height.
  • logs - Returns logs that are included in new imported blocks and match the given filter criteria. In case of a chain reorganization previous sent logs that are on the old chain will be resend with the removed property set to true. Logs from transactions that ended up in the new chain are emitted. Therefore a subscription can emit logs for the same transaction multiple times.
    • address (optional) - either an address or an array of addresses. Only logs that are created from these addresses are returned (optional)
    • topics (optional) - only logs which match the specified topics (optional)
Example
>wscat -c wss://ws.kardiachain.io

// newHeads
>{"jsonrpc":"2.0", "id": 1, "method": "kai_subscribe", "params": ["newHeads"]}

// logs
>{"jsonrpc":"2.0", "id": 1, "method": "kai_subscribe", "params": ["logs", {"address": "0x8320fe7702b96808f7bbc0d4a888ed1468216cfd", "topics": ["0xd78a0cb8bb633d06981248b816e7bd33c2a35a6089241d099fa519e361cab902"]}]}

RESPONSE

RESULT FIELDS

SUBSCRIPTION ID - ID of the newly created subscription on the node

BODY
// New Subscription response
{
    "id": 1, 
    "jsonrpc": "2.0", 
    "result": "0x9cef478923ff08bf67fde6c64013158d"
}

// newHeads
{
  "jsonrpc": "2.0",
  "method": "kai_subscription",
  "params": {
    "subscription": "0xe16adeb6aeb529071adb92190bd3a8c4",
    "result": {
      "height": 721956,
      "time": "2021-06-07T06:56:52.681398155Z",
      "numTxs": 0,
      "gasLimit": 150000000,
      "lastBlockID": {
        "hash": "0xf2205d5eaefaef4135f923c5ca7554353f3dd4c97d8b18df7b2577788ee7a481",
        "parts": {
          "total": 1,
          "hash": "0x64a494cdc0e1cfaf2ec46739dc2b2ff1ce00cdc31b81879035ce73e3c25cdd1b"
        }
      },
      "proposerAddress": "0x31e865160c245b378fe46d6b410da53168d6c1b0",
      "commitHash": "0x5ce2f2ab982ce360885e0e955028d1ca2e3e6a179e4f68064d77fb69725624ac",
      "dataHash": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
      "validatorHash": "0x89fc1c72329bb9777d3c45e84a2038a040141c0ee3ae85bad96f0a9351c3b468",
      "nextValidatorHash": "0x89fc1c72329bb9777d3c45e84a2038a040141c0ee3ae85bad96f0a9351c3b468",
      "consensusHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "appHash": "0x51145eae50bddfbce844c679fe96a8c9fb30159b2d3e43a5cff150b54f0d8e0a",
      "evidenceHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
    }
  }
}

// logs Subscription
{
    "jsonrpc": "2.0",
    "id": 1,
    "result":  [
        {
            "address": "0xf35a869a0f96dfd6bce6d57ecf9ef5a883b59c61",
            "topics": [
                "0xb0d234274aef7a61aa5a2eb44c23881ebf46a068cccbd413c978bcbd555fe17f"
            ],
            "data": "0x000000000000000000000000c1fe56e3f58d3244f606306611a5d10c8333f1f600000000000000000000000000000000000000000000054b40b1f852bda00000",
            "blockHeight": 5,
            "transactionHash": "0x8d8d38bf099ec1a3b5bcc4dbc091dc62020236023863f7afb6f852a9d4828a0b",
            "transactionIndex": 0,
            "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
            "logIndex": 1,
            "removed": false
        }, {
            ...
        }]
}

kai_unsubscribe

Subscriptions are cancelled with a regular RPC call with kai_unsubscribe as method and the subscription id as first parameter. It returns a bool indicating if the subscription was cancelled successful.

REQUEST PARAMS

SUBSCRIPTION ID [required]

Example
>wscat -c wss://ws.kardiachain.io

>{"jsonrpc":"2.0", "id": 1, "method": "kai_unsubscribe", "params": ["0x9cef478923ff08bf67fde6c64013158d"]}

RESPONSE

RESULT FIELDS

UNSUBSCRIBED FLAG - true if the subscription was cancelled successful.

BODY
{
    "id": 1, 
    "jsonrpc": "2.0", 
    "result": true
}
Clone this wiki locally