-
Notifications
You must be signed in to change notification settings - Fork 18
Web3 compatible JSON RPC APIs
JSON is a lightweight data-interchange format. It can represent numbers, strings, ordered sequences of values, and collections of name/value pairs.
JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. Primarily this specification defines several data structures and the rules around their processing. It is transport agnostic in that the concepts can be used within the same process, over sockets, over HTTP, or in many various message passing environments. It uses JSON (RFC 4627) as data format.
At present there are two key datatypes that are passed over JSON: unformatted byte arrays and quantities. Both are passed with a hex encoding, however with different requirements to formatting:
When encoding QUANTITIES (integers, numbers): encode as hex, prefix with "0x", the most compact representation (slight exception: zero should be represented as "0x0"). Examples:
- 0x41 (65 in decimal)
- 0x400 (1024 in decimal)
- WRONG: 0x (should always have at least one digit - zero is "0x0")
- WRONG: 0x0400 (no leading zeroes allowed)
- WRONG: ff (must be prefixed 0x)
When encoding UNFORMATTED DATA (byte arrays, account addresses, hashes, bytecode arrays): encode as hex, prefix with "0x", two hex digits per byte. Examples:
- 0x41 (size 1, "A")
- 0x004200 (size 3, "\0B\0")
- 0x (size 0, "")
- WRONG: 0xf0f0f (must be even number of digits)
- WRONG: 004200 (must be prefixed 0x)
The following methods have an extra default block parameter:
When requests are made that act on the state of KardiaChain, the last default block parameter determines the height of the block.
The following options are possible for the defaultBlock parameter:
-
HEX String
- an integer block number -
String "earliest"
for the earliest/genesis block -
String "latest"
- for the latest mined block -
String "pending"
- for the pending state/transactions
The curl options 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. 127.0.0.1:8545
The complete Postman collection with examples can be found here.
- web3_clientVersion (also available as eth_clientVersion)
- web3_sha3 (also available as eth_sha3)
- net_version
- eth_gasPrice
- eth_blockNumber
- eth_getBalance
- eth_getTransactionCount
- eth_getCode
- eth_sendRawTransaction
- eth_call
- eth_estimateGas
- eth_getBlockByHash
- eth_getBlockByNumber
- eth_getTransactionByHash
- eth_getTransactionReceipt
- eth_newFilter
- eth_newBlockFilter
- eth_newPendingTransactionFilter
- eth_uninstallFilter
- eth_getFilterChanges
- eth_getFilterLogs
- eth_getLogs
- debug_traceTransaction
- debug_traceCall
- txpool_content
- txpool_inspect
- txpool_status
Returns the current client version.
none
String
- The current client version
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "web3_clientVersion",
"params": [],
"id": 1
}'
// Result
{
"jsonrpc":"2.0",
"id":1,
"result": "KAI-Genesis-Validator-1/v1.5.0/linux-amd64/go1.14.12"
}
Returns Keccak-256 (not the standardized SHA3-256) of the given data.
none
Object
- list of peers which current node connects to.
-
DATA
- the data to convert into a SHA3 hash
params: ["0x68656c6c6f20776f726c64"];
DATA
- The SHA3 result of the given string.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "web3_sha3",
"params": [
"0x68656c6c6f20776f726c64"
],
"id": 1
}'
// Result
{
"jsonrpc":"2.0",
"id":1,
"result": "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"
}
Returns the current network id.
none
String
- The current network id.
-
"0"
: KardiaChain Aris Mainnet -
"69"
: KardiaChain Testnet
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "net_version",
"params": [],
"id": 1
}'
// Result
{
"jsonrpc":"2.0",
"id":1,
"result": "0"
}
Returns the current price per gas in HYDRO.
none
QUANTITY
- integer of the current gas price in wei.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": [],
"id": 1
}'
// Result
{
"jsonrpc":"2.0",
"id":1,
"result": "0x1dfd14000" // 8049999872 HYDRO
}
Returns the height of the most recent block.
none
QUANTITY
- integer of the current block height the client is on.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}'
// Result
{
"jsonrpc":"2.0",
"id":1,
"result": "0x4b7" // 1207
}
Returns the balance of the account of given address.
-
DATA
, 20 Bytes - address to check for balance. -
QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter.
params: [
"0x407d73d8a49eeb85d32cf465507dd71d507100c1",
"latest", // state at the latest block
];
QUANTITY
- integer of the current balance in HYDRO.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": [
"0x407d73d8a49eeb85d32cf465507dd71d507100c1",
"latest"
],
"id": 1
}'
// Result
{
"jsonrpc":"2.0",
"id":1,
"result": "0x0234c8a3397aab58" // 158972490234375000
}
Returns the number of transactions sent from an address.
-
DATA
, 20 Bytes - address to check for balance. -
QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter.
params: [
"0x407d73d8a49eeb85d32cf465507dd71d507100c1",
"latest", // state at the latest block
];
QUANTITY
- integer of the number of transactions send from this address.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": [
"0x407d73d8a49eeb85d32cf465507dd71d507100c1",
"latest"
],
"id": 1
}'
// Result
{
"jsonrpc":"2.0",
"id":1,
"result": "0x1" // 1
}
Returns code at a given address.
-
DATA
, 20 Bytes - address to check for code. -
QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter.
params: [
"0x407d73d8a49eeb85d32cf465507dd71d507100c1",
"latest", // state at the latest block
];
QUANTITY
- integer of the number of transactions send from this address.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": [
"0x407d73d8a49eeb85d32cf465507dd71d507100c1",
"latest"
],
"id": 1
}'
// Result
{
"jsonrpc":"2.0",
"id":1,
"result": "0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056"
}
Returns the value from a storage position at a given address.
-
DATA
, 20 Bytes - address of the storage. -
QUANTITY
- integer of the position in the storage. -
QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter.
"params": [
"0xe32Be8f73f0093dbef8b01705553ff299D609BF3",
"0x0",
"latest"
]
DATA
- the value at this storage position.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getStorageAt",
"params": [
"0xe32Be8f73f0093dbef8b01705553ff299D609BF3",
"0x0",
"latest"
],
"id": 1
}'
// Result
{
"jsonrpc":"2.0",
"id":1,
"result": "0x00000000000000000000000000000000000000000000000000000000000003d2"
}
Creates new message call transaction or a contract creation for signed transactions.
-
DATA
, The signed transaction data.
params: [
"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
];
DATA
, 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.
Use eth_getTransactionReceipt to get the contract address, after the transaction was mined, when you created a contract.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_sendRawTransaction",
"params": [{see above}],
"id": 1
}'
// Result
{
"jsonrpc":"2.0",
"id":1,
"result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}
Executes a new message call immediately without creating a transaction on the block chain.
-
Object
- The transaction call object.
-
from
:DATA
, 20 Bytes - (optional) The address the transaction is sent from. -
to
:DATA
, 20 Bytes - The address the transaction is directed to. -
gas
:QUANTITY
- (optional) Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions. -
gasPrice
:QUANTITY
- (optional) Integer of the gasPrice used for each paid gas. -
value
:QUANTITY
- (optional) Integer of the value sent with this transaction. -
data
:DATA
- (optional) Hash of the method signature and encoded parameters.
-
QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter.
DATA
- the return value of executed contract.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{see above}],
"id": 1
}'
// Result
{
"jsonrpc":"2.0",
"id":1,
"result": "0x"
}
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 KVM mechanics and node performance.
See eth_call 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.
QUANTITY
- the amount of gas used.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_estimateGas",
"params": [{see above}],
"id": 1
}'
// Result
{
"jsonrpc":"2.0",
"id":1,
"result": "0x7148" // 29000
}
Returns information about a block by hash.
-
DATA
, 32 Bytes - Hash of a block. -
Boolean
- Iftrue
it returns the full transaction objects, iffalse
only the hashes of the transactions.
params: [
"0x985803c8e1ac9b60c91b786a40ca454fe2efbc2e5ff9e499c58f656ffa9bbc9e",
false,
];
Object
- A block object, or null
when no block was found:
-
number
:QUANTITY
- the block number.null
when its pending block. -
hash
:DATA
, 32 Bytes - hash of the block.null
when its pending block. -
parentHash
:DATA
, 32 Bytes - hash of the parent block. -
nonce
:DATA
, 8 Bytes - hash of the generated proof-of-work.null
when its pending block. -
sha3Uncles
:DATA
, 32 Bytes - SHA3 of the uncles data in the block. -
logsBloom
:DATA
, 256 Bytes - the bloom filter for the logs of the block.null
when its pending block. -
transactionsRoot
:DATA
, 32 Bytes - the root of the transaction trie of the block. -
stateRoot
:DATA
, 32 Bytes - the root of the final state trie of the block. -
receiptsRoot
:DATA
, 32 Bytes - the root of the receipts trie of the block. -
miner
:DATA
, 20 Bytes - address of the chosen proposer who finalizing this block. -
difficulty
:QUANTITY
- integer of the difficulty for this block. -
extraData
:DATA
- the “extra data” field of this block. -
size
:QUANTITY
- integer the size of this block in bytes. -
gasLimit
:QUANTITY
- the maximum gas allowed in this block. -
gasUsed
:QUANTITY
- the total used gas by all transactions in this block. -
timestamp
:QUANTITY
- the unix timestamp for when the block was collated. -
transactions
:Array
- Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter. -
commitHash
:DATA
- hash of last commit.null
when it's the pending block. -
consensusHash
:DATA
, 32 Bytes - hash of the block consensus. -
evidenceHash
:DATA
, 32 Bytes - hash evidences list. -
mixHash
:DATA
, 32 Bytes - the hash that was used as an input to the PoW process. -
validatorsHash
:DATA
, 32 Bytes - hash of the current validators set. -
nextValidatorHash
:DATA
, 32 Bytes - hash of the next validators set. -
numTxs
:QUANTITY
- the number of transactions in the block.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"params": [
"0x985803c8e1ac9b60c91b786a40ca454fe2efbc2e5ff9e499c58f656ffa9bbc9e",
false
],
"id": 1
}'
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"commitHash": "0x7ed0bf757e6ddd11e7843d5b6fba4d72fce699699abbf211932faff67595bee8",
"consensusHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x000000",
"evidenceHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0xbebc200",
"gasUsed": "0x0",
"hash": "0x985803c8e1ac9b60c91b786a40ca454fe2efbc2e5ff9e499c58f656ffa9bbc9e",
"miner": "0x416dAadf88692d93Bdc0d89aB0bb149e3FFaF8bd",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nextValidatorHash": "0x5faf550a59a635b588d37e08622f20ad8bd17347e22c1e0f9dfed1a3880180be",
"nonce": "0x0000000000000000",
"numTxs": "0x0",
"number": "0x5",
"parentHash": "0xcad31e5ab0ee5dbd834cb257fdd24eb68d539de24605e0c5567ecd093271d364",
"receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"sha3Uncles": "0x0000000000000000000000000000000000000000000000000000000000000000",
"size": "0x000000",
"stateRoot": "0x94544cbb95ab8ec6e13d7cdb6ca87cbcf030c46d34d63248432bef7892c5d326",
"timestamp": "0x5feb1a68",
"transactions": [],
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"validatorHash": "0x5faf550a59a635b588d37e08622f20ad8bd17347e22c1e0f9dfed1a3880180be"
}
}
Returns information about a block by block number.
-
QUANTITY|TAG
- integer of a block number, or the string"earliest"
,"latest"
or"pending"
, as in the default block parameter. -
Boolean
- Iftrue
it returns the full transaction objects, iffalse
only the hashes of the transactions.
"params": [
"0x5",
true
]
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": [
"0x5",
true
],
"id": 1
}'
Result see eth_getBlockByHash
Returns the information about a transaction requested by transaction hash.
-
DATA
, 32 Bytes - hash of a transaction
params: ["0x50366c39b8103bccb9f4f2691adf3141aa66c2412acd2cbfe78e9150f7c68f47"];
Object
- A transaction object, or null
when no transaction was found:
-
blockHash
:DATA
, 32 Bytes - hash of the block where this transaction was in.null
when its pending. -
blockNumber
:QUANTITY
- block number where this transaction was in.null
when its pending. -
from
:DATA
, 20 Bytes - address of the sender. -
gas
:QUANTITY
- gas provided by the sender. -
gasPrice
:QUANTITY
- gas price provided by the sender in HYDRO. -
hash
:DATA
, 32 Bytes - hash of the transaction. -
input
:DATA
- the data send along with the transaction. -
nonce
:QUANTITY
- the number of transactions made by the sender prior to this one. -
to
:DATA
, 20 Bytes - address of the receiver.null
when its a contract creation transaction. -
transactionIndex
:QUANTITY
- integer of the transactions index position in the block.null
when its pending. -
value
:QUANTITY
- value transferred in HYDRO. -
v
:QUANTITY
- ECDSA recovery id -
r
:DATA
, 32 Bytes - ECDSA signature r -
s
:DATA
, 32 Bytes - ECDSA signature s
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getTransactionByHash",
"params": [
"0x50366c39b8103bccb9f4f2691adf3141aa66c2412acd2cbfe78e9150f7c68f47"
],
"id": 1
}'
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"blockHash": "0xd6dbf385a6beeeb9c685074215133ef8874569854b1e74420bd2445e0db86826",
"blockNumber": "0x494ef2",
"from": "0x0eb8d1732d150bb32dc54b605ded3e4ed85905d9",
"gas": "0x4c4b40",
"gasPrice": "0x3b9aca00",
"hash": "0x50366c39b8103bccb9f4f2691adf3141aa66c2412acd2cbfe78e9150f7c68f47",
"input": "0xb4ab979e0000000000000000000000000000000000000000000000000000000000000d0d",
"nonce": "0x3836",
"to": "0xe5daa2925c7e6bc9e6f46abd6d0c4004c287919f",
"transactionIndex": "0x9",
"value": "0x0",
"type": "0x0",
"v": "0x1c",
"r": "0x2159c7600bdf1ae58e72a10343fd97cc69949044939c7152f5d656a177eea5dc",
"s": "0x211df45ba39f4aed506375944fa70d0177c930c3396f782c5fe493a0b4ac6855"
}
}
Returns the receipt of a transaction by transaction hash.
Note That the receipt is not available for pending transactions.
-
DATA
, 32 Bytes - hash of a transaction.
Object
- A transaction receipt object, or null
when no receipt was found:
-
transactionHash
:DATA
, 32 Bytes - hash of the transaction. -
transactionIndex
:QUANTITY
- integer of the transactions index position in the block. -
blockHash
:DATA
, 32 Bytes - hash of the block where this transaction was in. -
blockNumber
:QUANTITY
- block number where this transaction was in. -
from
:DATA
, 20 Bytes - address of the sender. -
to
:DATA
, 20 Bytes - address of the receiver.null
when its a contract creation transaction. -
cumulativeGasUsed
:QUANTITY
- The total amount of gas used when this transaction was executed in the block. -
gasUsed
:QUANTITY
- The amount of gas used by this specific transaction alone. -
contractAddress
:DATA
, 20 Bytes - The contract address created, if the transaction was a contract creation, otherwisenull
. -
logs
:Array
- Array of log objects, which this transaction generated. -
logsBloom
:DATA
, 256 Bytes - Bloom filter for light clients to quickly retrieve related logs. -
status
:QUANTITY
either1
(success) or0
(failure)
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getTransactionReceipt",
"params": [
"0x50366c39b8103bccb9f4f2691adf3141aa66c2412acd2cbfe78e9150f7c68f47"
],
"id": 1
}'
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"blockHash": "0xd6dbf385a6beeeb9c685074215133ef8874569854b1e74420bd2445e0db86826",
"blockNumber": "0x494ef2",
"contractAddress": null,
"cumulativeGasUsed": "0x11d9a9",
"from": "0x0eb8d1732d150bb32dc54b605ded3e4ed85905d9",
"gasUsed": "0xc04a",
"logs": [
{
"address": "0xe5daa2925c7e6bc9e6f46abd6d0c4004c287919f",
"topics": [
"0x046d39ff823e39e327f08e23e6db8f8947f1a3b2ec30af9fb8057506960d6ad0"
],
"data": "0x0000000000000000000000000000000000000000000000000000000000000d0d0000000000000000000000000000000000000000000000000000000000001612000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000616907c0",
"blockNumber": "0x494ef2",
"transactionHash": "0x50366c39b8103bccb9f4f2691adf3141aa66c2412acd2cbfe78e9150f7c68f47",
"transactionIndex": "0x9",
"blockHash": "0xd6dbf385a6beeeb9c685074215133ef8874569854b1e74420bd2445e0db86826",
"logIndex": "0x2f",
"removed": false
}
],
"logsBloom": "0x00280000000000000000001080100000000000001400000800000010000000002200000001180000000004800000010009440000002000000000100000240000000000000c00000000000008000080200000000000040008080000400000000400000006020000100000400008000800000000000000000008004011000000080000000020000800000100000220000000000000080000080000004000000000020000000001000000000000000000000000040000000000100001000010080000000002000000000000000040000040000000000000045000002000000060000090040004000001000000000040020008000002400000004000000000000000",
"status": "0x1",
"to": "0xe5daa2925c7e6bc9e6f46abd6d0c4004c287919f",
"transactionHash": "0x50366c39b8103bccb9f4f2691adf3141aa66c2412acd2cbfe78e9150f7c68f47",
"transactionIndex": "0x9"
}
}
Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call eth_getFilterChanges.
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)”
-
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 BytesDATA
topics. Topics are order-dependent. Each topic can also be an array of DATA with “or” options.
"params": [
{
"fromBlock": "0x49518c",
"toBlock": "0x49518c",
"address": "0x5995F16246DfA676A44B8bD7E751C1226093dcd7",
"topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
}
]
QUANTITY
- A filter id.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_newFilter",
"params": [
{
"fromBlock": "0x49518c",
"toBlock": "0x49518c",
"address": "0x5995F16246DfA676A44B8bD7E751C1226093dcd7",
"topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
}
],
"id": 1
}'
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x19698b2fad447503894bbeb1255c6804"
}
Creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call eth_getFilterChanges.
None
QUANTITY
- A filter id.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_newBlockFilter",
"params": [],
"id": 1
}'
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": "0xa673a699237c1e2a4f10093ea11b3f1b"
}
Creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call eth_getFilterChanges.
None
QUANTITY
- A filter id.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_newPendingTransactionFilter",
"params": [],
"id": 1
}'
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": "0xa673a699237c1e2a4f10093ea11b3f1b"
}
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 eth_getFilterChanges for a period of time.
-
QUANTITY
- The filter id.
"params": [
"0xa0eaf5f4cfdaa2841e2ceb82e3d3eb86"
]
Boolean
- true
if the filter was successfully uninstalled, otherwise false
.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_uninstallFilter",
"params": [
"0xa0eaf5f4cfdaa2841e2ceb82e3d3eb86"
],
"id": 1
}'
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": true
}
Polling method for a filter, which returns an array of logs which occurred since last poll.
-
QUANTITY
- The filter id.
"params": [
"0xa0eaf5f4cfdaa2841e2ceb82e3d3eb86"
]
Array
- Array of log objects, or an empty array if nothing has changed since last poll.
- For filters created with
eth_newBlockFilter
the return are block hashes (DATA
, 32 Bytes), e.g.["0x3454645634534..."]
. - For filters created with
eth_newPendingTransactionFilter
the return are transaction hashes (DATA
, 32 Bytes), e.g.["0x6345343454645..."]
. - For filters created with
eth_newFilter
logs are objects with following params:-
removed
:TAG
-true
when the log was removed, due to a chain reorganization.false
if its a valid log. -
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 log. -
blockNumber
:QUANTITY
- the block number where this log was in.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 1 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 theanonymous
specifier.)
-
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getFilterChanges",
"params": [
"0x2dc54beff33d85789d9d4ec173bbe94e"
],
"id": 1
}'
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"address": "0x5995f16246dfa676a44b8bd7e751c1226093dcd7",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000005b60a5761047b3a9ec340941d904231be85f5c0b",
"0x000000000000000000000000037d453c6e2c80c25615bc17b12335e81726ad1d"
],
"data": "0x000000000000000000000000000000000000000000000000000b6e9e2273d80b",
"blockNumber": "0x495236",
"transactionHash": "0x3dcddf8948678431731a0e38c7418f5d8b0c0c4b08953e5668a72dfbba6e75b6",
"transactionIndex": "0x4",
"blockHash": "0x3ead7c291a04c3c3757d77702e02265c6a03a60ea4253403de7093511fc780af",
"logIndex": "0xd",
"removed": false
}
]
}
Returns an array of all logs matching filter with given id.
-
QUANTITY
- The filter id.
"params": [
"0xa0eaf5f4cfdaa2841e2ceb82e3d3eb86"
]
See eth_getFilterChanges.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getFilterLogs",
"params": [
"0xa0eaf5f4cfdaa2841e2ceb82e3d3eb86"
],
"id": 1
}'
Result see eth_getFilterChanges.
Returns an array of all logs matching a given filter object.
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 BytesDATA
topics. Topics are order-dependent. Each topic can also be an array ofDATA
with “or” options. -
blockhash
:DATA
, 32 Bytes - (optional)blockHash
will be a new filter option which restricts the logs returned to the single block with the 32-byte hashblockHash
. UsingblockHash
is equivalent tofromBlock
=toBlock
= the block number with hashblockHash
. IfblockHash
is present in in the filter criteria, then neitherfromBlock
nortoBlock
are allowed.
params: [
{
fromBlock: "0x49518c",
toBlock: "0x49518c",
address: "0x5995F16246DfA676A44B8bD7E751C1226093dcd7",
topics: [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
],
},
];
See eth_getFilterChanges.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [
{
"fromBlock": "0x49518c",
"toBlock": "0x49518c",
"address": "0x5995F16246DfA676A44B8bD7E751C1226093dcd7",
"topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
}
],
"id": 1
}'
Result see eth_getFilterChanges.
The traceTransaction
debugging method will attempt to run the transaction in the exact same manner as it was executed on the network. It will replay any transaction that may have been executed prior to this one before it will finally attempt to execute the transaction that corresponds to the given hash.
In addition to the hash of the transaction you may give it a secondary optional argument, which specifies the options for this specific call.
-
DATA
- hash of the transaction to debug
The possible optional arguments are:
-
disableStorage
:BOOL
- Setting this to true will disable storage capture (default =false
). -
disableMemory
:BOOL
- Setting this to true will disable memory capture (default =false
). -
disableStack
:BOOL
- Setting this to true will disable stack capture (default =false
). -
tracer
:STRING
- Setting this will enable JavaScript-based transaction tracing, described below. If set, the previous four arguments will be ignored. -
timeout
:STRING
- Overrides the default timeout of 5 seconds for JavaScript-based tracing calls. Valid values are described (here)[https://pkg.go.dev/time#ParseDuration].
"params": [
"0x8271c264a56ee5dee332f771b7e309a749d20b2db19dd178adf6308a440fd25e",
{"tracer": "{data: [], fault: function(log) {}, step: function(log) { if(log.op.toString() == \"PUSH1\") this.data.push(log.stack.peek(0)); }, result: function() { return this.data; }}"}
]
Object
- debugging and execution details of a transaction.
-
gas
:QUANTITY
- gas used by the transaction. -
failed
:Boolean
-true
if the transaction is reverted during execution, otherwisefalse
. -
returnValue
:DATA
- the returned value of the transaction call. -
revertReason
:String
- the reason makes the transaction reverted, defined by therequire
command in solidity. -
structLogs
:Array of Object
- details of each OPCODE execution during the transaction execution.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "debug_traceTransaction",
"params": [
"0x8271c264a56ee5dee332f771b7e309a749d20b2db19dd178adf6308a440fd25e"
],
"id": 1
}'
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"gas": 48736,
"failed": false,
"returnValue": "",
"revertReason": "",
"structLogs": [
{
"pc": 0,
"op": "PUSH1",
"gas": 4970472,
"gasCost": 3,
"depth": 1,
"stack": [],
"memory": [],
"storage": {}
},...
]
}
}
The debug_traceCall
method lets you run an eth_call
within the context of the given block execution using the final state of parent block as the base. The block can be specified either by hash or by number. It takes the same input object as a eth_call
. It returns the same output as debug_traceTransaction
. A tracer can be specified as a third argument, similar to debug_traceTransaction
.
See eth_call
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "debug_traceCall",
"params": [
{
"data": "0x70a0823100000000000000000000000005C5cCf9d97B212D9F7D959fE8e0F669192A2FD1",
"from": "0xE6c93752e359272e25f9940E97E730d76d87A8b8",
"gasPrice": "0x0",
"to": "0x1790A6be515A88d5d972224098bC5A7EBdb01F8C",
"value": "0x0"
},
"latest",
{"disableStorage":true, "disableMemory": true}
],
"id": 1
}'
Result see debug_traceTransaction
The content
inspection property can be queried to list the exact details of all the transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future execution only.
The result is an object with two fields pending
and queued
. Each of these fields are associative arrays, in which each entry maps an origin-address to a batch of scheduled transactions. These batches themselves are maps associating nonces with actual transactions.
Please note, there may be multiple transactions associated with the same account and nonce. This can happen if the user broadcast mutliple ones with varying gas allowances (or even completely different transactions).
None
Object
- contains pending
and queued
transactions in pool.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "txpool_content",
"params": [],
"id": 1
}'
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"pending": {
"0x4A956d227b2045369eB00C586288ACC3A1E53637": {
"0": {
"blockHash": null,
"blockNumber": null,
"from": "0x4a956d227b2045369eb00c586288acc3a1e53637",
"gas": "0x7148",
"gasPrice": "0x3b9aca00",
"hash": "0x0d5f595c6a3e9ece537d61fe2b36b53bb515b1f6976152151ca20aaaba3a7174",
"input": "0x",
"nonce": "0x0",
"to": "0x0e78afee688769865b56226a9eb29bc0c6629e9b",
"transactionIndex": null,
"value": "0xde0b6b3a7640000",
"v": "0x1c",
"r": "0xec5ec2774fd95f70cafac11e23bfaee14ae0e1c9ccc9f2a5b0b8f7f3c23fc3e4",
"s": "0x1325b62fe8200bc2d5bb4e1d9fce17f46bef9683baa0f9085101b8477f1a856a"
}
}
},
"queued": {
"0x4A956d227b2045369eB00C586288ACC3A1E53637": {
"3": {
"blockHash": null,
"blockNumber": null,
"from": "0x4a956d227b2045369eb00c586288acc3a1e53637",
"gas": "0x7148",
"gasPrice": "0x4190ab00",
"hash": "0x413ff0f02f17961661af4cf70cf83f78ccc4d7885f11ef49cb162d5731c227a6",
"input": "0x",
"nonce": "0x3",
"to": "0x0e78afee688769865b56226a9eb29bc0c6629e9b",
"transactionIndex": null,
"value": "0xde0b6b3a7640000",
"v": "0x1c",
"r": "0x79c87b41fbdf19272a3ae6f552452e1ce5817adddda0b32f28a738aaaeff9435",
"s": "0x4eb4427642a821e35fc13e792a4250f0ec9c9a3135d991216b35b393d961964"
}
}
}
}
}
The inspect
inspection property can be queried to list a textual summary of all the transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future execution only. This is a method specifically tailored to developers to quickly see the transactions in the pool and find any potential issues.
The result is an object with two fields pending
and queued
. Each of these fields are associative arrays, in which each entry maps an origin-address to a batch of scheduled transactions. These batches themselves are maps associating nonces with transactions summary strings.
Please note, there may be multiple transactions associated with the same account and nonce. This can happen if the user broadcast mutliple ones with varying gas allowances (or even completely different transactions).
None
Object
- contains pending
and queued
transactions with nonce, hash and transaction fee details in pool.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "txpool_content",
"params": [],
"id": 1
}'
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"pending": {
"0x0D9580eA6B89cBE589EE6687FfB40AcB1C5435a1": {
"318": "0xE5dAA2925C7E6Bc9e6F46aBd6d0c4004C287919f: 0 HYDRO + 5000000 gas × 1000000000 HYDRO"
}
"0x934F52e8FB4De610868a9bebD4649f482BBFF201": {
"38": "0xc80ACe0aC969397F96a8E1c97D21B4759fAFeB1E: 0 HYDRO + 3000000 gas × 1000000000 HYDRO",
"39": "0xc80ACe0aC969397F96a8E1c97D21B4759fAFeB1E: 0 HYDRO + 3000000 gas × 1000000000 HYDRO"
}
},
"queued": {
"0x39B3ddAb4A0264191d9a32791A232bD8b58D09FC": {
"19361": "0xF981cF6DC8831Fe6D62E93e682eA40605953C2EF: 0 HYDRO + 300000 gas × 10000000000 HYDRO",
"19362": "0xF981cF6DC8831Fe6D62E93e682eA40605953C2EF: 0 HYDRO + 300000 gas × 10000000000 HYDRO"
},
"0xAbbc7eCfc5da1e8ce456DF8Cb38a40c5a8698458": {
"843": "0xE5dAA2925C7E6Bc9e6F46aBd6d0c4004C287919f: 0 HYDRO + 5000000 gas × 1000000000 HYDRO"
}
}
}
}
The status
inspection property can be queried for the number of transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future execution only.
The result is an object with two fields pending
and queued
, each of which is a counter representing the number of transactions in that particular state.
None
Object
- contains total number of pending
and queued
transactions currently in pool.
// Request
curl --location --request POST 'https://rpc.kardiachain.io/' \
--header "Content-Type: application/json" \
--data-raw '{
"jsonrpc": "2.0",
"method": "txpool_status",
"params": [],
"id": 1
}'
// Result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"pending": "0x7",
"queued": "0x3"
}
}