JSON-RPC
IMPORTANT NOTICE (February 2021): Starting from conflux-rust v1.1.1
, all hex addresses used in the RPCs below have been updated to base32 addresses, as defined in CIP-37. For converting legacy hex addresses into base32 addresses, please refer to conflux-address-js or use the conversion tool on Conflux Scan.
The Conflux JSON-RPC API is a collection of interfaces that allow you to interact with a local or remote Conflux node. You can use this API through an HTTP, TCP, or WebSocket connection.
The following is an API reference documentation with examples.
JSON-RPC#
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 its data format.
JSON-RPC endpoints#
Currently, Conflux has a Rust implementation that supports JSON-RPC 2.0 over an HTTP, TPC, or WebSocket connection.
If you are a node operator, you can enable and configure various RPC interfaces through the TOML config file, or directly by passing command line arguments. The main configuration items are listed in the table below. Note that if you want to enable HTTPS or access control, you will need to set up a proxy for your node.
jsonrpc_ws_port
--jsonrpc-ws-port
12535
no
jsonrpc_tcp_port
--jsonrpc-tcp-port
12536
no
jsonrpc_http_port
--jsonrpc-http-port
12537
no
jsonrpc_local_tcp_port
-
12538
no
jsonrpc_local_http_port
-
12539
yes
The examples in the rest of this document will use the HTTP endpoint.
HEX value encoding#
At present, there are two key data types that are passed over JSON: unformatted byte arrays and quantities. While both are encoded as hex strings, they have different formatting requirements:
When encoding QUANTITIES (integers, numbers): encode as hex using the most compact representation and prefix with "0x"
. 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
(missing0x
prefix)
When encoding UNFORMATTED DATA (byte arrays, hashes, bytecode arrays): encode as hex using two hex digits per byte and prefix with "0x"
. Examples:
0x41
(size 1,"A"
)0x004200
(size 3,"\0B\0"
)0x
(size 0,""
)WRONG:
0xf0f0f
(must be even number of digits)WRONG:
004200
(missing0x
prefix)
Note that block and transaction hashes are represented using 32 bytes.
BASE32
: Base32 addresses should be encoded as an ASCII string of 42-characters plus network prefix, separators, and optional fields. Please note the following constraints for base32 addresses as RPC parameters:
The network-prefix should match the node's network, i.e.
cfx:acc7uawf5ubtnmezvhu9dhc6sghea0403y2dgpyfjp
can be sent to mainnet nodes andcfxtest:acc7uawf5ubtnmezvhu9dhc6sghea0403ywjz6wtpg
can be sent to testnet nodes. Note that these two example addresses correspond to the same account on different networks.Including and omitting the address-type are both accepted, i.e.
cfx:aarc9abycue0hhzgyrr53m6cxedgccrmmyybjgh4xg
andcfx:type.user:aarc9abycue0hhzgyrr53m6cxedgccrmmyybjgh4xg
are equivalent. However, addresses with an incorrect type, e.g.cfx:type.contract:aarc9abycue0hhzgyrr53m6cxedgccrmmyybjgh4xg
, are rejected.Both lowercase (
cfx:aarc9abycue0hhzgyrr53m6cxedgccrmmyybjgh4xg
) and uppercase (CFX:AARC9ABYCUE0HHZGYRR53M6CXEDGCCRMMYYBJGH4XG
) addresses are accepted. Mixed-case addresses are rejected.
The epoch number parameter#
Several RPC methods have an epoch number parameter. The concept of epochs in Conflux is somewhat analogous to the concept of block numbers (height) in other ledgers, but one epoch might contain multiple blocks.
The epoch number specifies a point in time and the corresponding state of the system, subject to consensus. The following options are possible for the epoch number parameter:
HEX String
- an integer epoch number. For example,0x3e8
is epoch 1000.String "earliest"
for the epoch of the genesis block.String "latest_checkpoint"
for the earliest epoch stored in memory.String "latest_finalized"
- for the latest finalized (by PoS) epoch. (Added from conflux-rustv2.0.0
)String "latest_confirmed"
- for the latest confirmed epoch (using the confirmation meter's estimate).String "latest_state"
- for the latest epoch that has been executed.String "latest_mined"
- for the latest known epoch.
Please note that due to performance optimization, the latest mined epochs are not executed, so there is no state available for these epochs. For most RPCs related to state query, "latest_state"
is recommended.
State and transaction availability#
Conflux archive and full nodes remove historical state tries to reduce storage use. Full nodes will also discard transactions and receipts for historical blocks. As a result, some RPC interfaces might be unavailable for historical queries.
Below is a list of the Conflux RPC APIs and their availability on archive and full nodes. "recent" means that the RPC is only supported for recent items, "OK" means that it should work for any valid input.
recent
recent
recent
recent
OK
OK
OK
OK
recent
recent
OK
OK
recent
recent
OK
OK
recent
recent
recent
recent
OK
OK
OK
recent
OK
recent
OK
recent
OK
recent
OK
OK
recent
recent
recent
recent
OK
recent
recent
recent
recent
recent
OK
recent
recent
recent
OK
OK
recent
recent
recent
recent
OK
OK
recent
recent
recent
recent
OK
recent
OK
recent
recent
recent
OK
OK
If you query a state entry that is unavailable on the node, you will get an error response:
In this example, we are told that the earliest available state is at epoch 9510001
(0x911c71
).
Migrating from Ethereum JSON-RPC#
There is a correspondence between some JSON-RPCs from Ethereum and Conflux. Even though the details of JSON-RPC may differ, the following mapping table could be helpful when migrating from Ethereum to Conflux:
eth_blockNumber
eth_call
eth_estimateGas
eth_gasPrice
eth_getBalance
eth_getBlockByHash
eth_getBlockByNumber
eth_getCode
eth_getLogs
eth_getStorageAt
eth_getTransactionByHash
eth_getTransactionCount
eth_getTransactionReceipt
eth_sendRawTransaction
JSON-RPC methods#
cfx_getTransactionByHash#
Returns information about a transaction, identified by its hash.
Parameters#
DATA
, 32 Bytes - hash of a transaction
Returns#
Object
- a transaction object, or null
when no transaction was found:
blockHash
:DATA
, 32 Bytes - hash of the block where this transaction was in and got executed.null
when the transaction is pending.chainId
:QUANTITY
- the chain ID specified by the sender.contractCreated
:BASE32
- address of the contract created.null
when it is not a contract deployment transaction.data
:DATA
- the data sent along with the transaction.epochHeight
:QUANTITY
- the epoch proposed by the sender. Note that this is NOT the epoch of the block containing this transaction.from
:BASE32
- address of the sender.gas
:QUANTITY
- gas provided by the sender.gasPrice
:QUANTITY
- gas price provided by the sender in Drip.hash
:DATA
, 32 Bytes - hash of the transaction.nonce
:QUANTITY
- the number of transactions made by the sender prior to this one.r
:DATA
, 32 Bytes - ECDSA signature r.s
:DATA
, 32 Bytes - ECDSA signature s.status
:QUANTITY
- 0 for success, 1 if an error occurred, 2 for skiped,null
when the transaction is skipped or not packed.storageLimit
:QUANTITY
- the storage limit specified by the sender.to
:BASE32
- address of the receiver.null
when it is a contract deployment transaction.transactionIndex
:QUANTITY
- the transaction's position in the block.null
when the transaction is pending.v
:QUANTITY
- ECDSA recovery id.value
:QUANTITY
- value transferred in Drip.
Note that the fields blockHash
, contractCreated
, status
, and transactionIndex
are provided by the node as they depend on the transaction's position within the ledger. The rest of the fields are included in or derived from the original transaction.
Example#
cfx_getBlockByHash#
Returns information about a block, identified by its hash.
Parameters#
DATA
, 32 Bytes - hash of a block.Boolean
- iftrue
, it returns the full transaction objects. Iffalse
, only the hashes of the transactions are returned.
Returns#
Object
- A block object, or null
when no block was found:
adaptive
:Boolean
-true
if the weight of the block is adaptive under the GHAST rule.blame
:QUANTITY
- if 0, then this block does not blame any blocks on its parent path. If it isn > 0
, then this block blames itsn
predecessors on its parent path, e.g. whenn = 1
, then the block blames its parent but not its parent's parent.deferredLogsBloomHash
:DATA
, 32 Bytes - the hash of the logs bloom after deferred execution at the block's epoch (assuming it is the pivot block).deferredReceiptsRoot
:DATA
, 32 Bytes - the Merkle root of the receipts after deferred execution at the block's epoch (assuming it is the pivot block).deferredStateRoot
:DATA
, 32 Bytes - the hash of the state trie root triplet after deferred execution at the block's epoch (assuming it is the pivot block).difficulty
:QUANTITY
- the PoW difficulty of this block.epochNumber
:QUANTITY
- the number of the epoch containing this block in the node's view of the ledger.null
when the epoch number is not determined (e.g. the block is not in the best block's past set).gasLimit
:QUANTITY
- the maximum gas allowed in this block.gasUsed
:QUANTITY
- the total gas used in this block.null
when the block is pending.hash
:DATA
, 32 Bytes - hash of the block.height
:QUANTITY
- the height of the block.miner
:BASE32
- the address of the beneficiary to whom the mining rewards were given.nonce
:DATA
, 8 Bytes - hash of the generated proof-of-work.parentHash
:DATA
, 32 Bytes - hash of the parent block.powQuality
:DATA
- the PoW quality.null
when the block is pending.refereeHashes
:Array
- array of referee block hashes.size
:QUANTITY
- the size of this block in bytes, excluding the block header.timestamp
:QUANTITY
- the unix timestamp for when the block was created.transactions
:Array
- array of transaction objects, or 32-byte transaction hashes, depending on the second parameter.transactionsRoot
:DATA
, 32 Bytes - the Merkle root of the transactions in this block.custom
:Array
- customized information.blockNumber
:QUANTITY
- the number of this block's total order in the tree-graph.null
when the order is not determined. Added fromConflux-rust v1.1.5
posReference
:DATA
, 32 Bytes - the hash of the PoS newest committed block. Added fromConflux-rust v2.0.0
Note that the fields epochNumber
and gasUsed
are provided by the node as they depend on the ledger. The rest of the fields are included in or derived from the block header directly.
Example#
cfx_getBlockByEpochNumber#
Returns information about a block, identified by its epoch number.
Parameters#
QUANTITY|TAG
- the epoch number, or the string"latest_mined"
,"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter.Boolean
- iftrue
, it returns the full transaction objects. Iffalse
, only the hashes of the transactions are returned
Returns#
See cfx_getBlockByHash.
Example#
Result see cfx_getBlockByHash.
cfx_getBestBlockHash#
Returns the hash of the best block.
Parameters#
None.
Returns#
DATA
, 32 Bytes - hash of the best block.
Example#
cfx_epochNumber#
Returns the epoch number corresponding to the given tag.
Parameters#
TAG
- (optional, default:"latest_mined"
) String"latest_mined"
,"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter.
Returns#
QUANTITY
- the integer epoch number corresponding to the given tag.
Example#
cfx_gasPrice#
Returns the current price per gas in Drip.
Parameters#
None.
Returns#
QUANTITY
- integer of the current gas price in Drip.
Example#
cfx_getBlocksByEpoch#
Returns the block hashes in the specified epoch.
Parameters#
QUANTITY|TAG
- the epoch number, or the string"latest_mined"
,"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter.
Returns#
Array
- array of block hashes, sorted by their execution (topological) order. Note that the last one is the pivot hash.
Example#
cfx_getBalance#
Returns the balance of the given account, identified by its address.
Parameters#
BASE32
- address to check for balance.QUANTITY|TAG
- (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
QUANTITY
- integer of the current balance in Drip.
Example#
cfx_getStakingBalance#
Returns the stacking balance of the given account, identified by its address.
Parameters#
BASE32
- address to check for staking balance.QUANTITY|TAG
- (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
QUANTITY
- integer of the current staking balance in Drip.
Example#
cfx_getCollateralForStorage#
Returns the size of the collateral storage of a given address, in bytes.
Parameters#
BASE32
- address to check for collateral storage.QUANTITY|TAG
- (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
QUANTITY
- integer of the collateral storage in Byte.
Example#
cfx_getAdmin#
Returns the admin of the specified contract.
Parameters#
BASE32
- address of the contract.QUANTITY|TAG
- (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
BASE32
- address of admin, or null
if the contract does not exist.
Example#
cfx_getCode#
Returns the code of the specified contract. If contract not exist will return 0x0
Parameters#
BASE32
- address of the contract.QUANTITY|TAG
- (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
DATA
- byte code of the contract, or 0x
if the account has no code. This RPC will raise an error if the account does not exist.
Example#
cfx_getStorageAt#
Returns storage entries from a given contract.
Parameters#
BASE32
- address of the contract.QUANTITY
- a storage position (see here for more info).QUANTITY|TAG
- (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
DATA
- 32 Bytes - the contents of the storage position, or null
if the contract does not exist.
Example#
cfx_getStorageRoot#
Returns the storage root of a given contract.
Parameters#
BASE32
- address of the contract.QUANTITY|TAG
- (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
Object
- A storage root object, or null
if the contract does not exist:
delta
:DATA
, 32 Bytes - the storage root in the delta trie, or the string"TOMBSTONE"
, ornull
.intermediate
:DATA
, 32 Bytes - storage root in the intermediate trie, or the string"TOMBSTONE"
, ornull
.snapshot
:DATA
, 32 Bytes - storage root in the snapshot, or the string"TOMBSTONE"
, ornull
.
If all three of these fields match for two invocations of this RPC, the contract's storage is guaranteed to be identical. If they do not match, storage has likely changed (or the system transitioned into a new era).
Example#
cfx_getSponsorInfo#
Returns the sponsor info of a given contract.
Parameters#
BASE32
- address of the contract.QUANTITY|TAG
- (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
Object
- A sponsor info object. If the contract doesn't have a sponsor, then all fields in the object returned will be 0
:
sponsorBalanceForCollateral
:QUANTITY
- the sponsored balance for storage.sponsorBalanceForGas
:QUANTITY
- the sponsored balance for gas.sponsorGasBound
:QUANTITY
- the max gas that could be sponsored for one transaction.sponsorForCollateral
:BASE32
- the address of the storage sponsor.sponsorForGas
:BASE32
- the address of the gas sponsor.
Example#
cfx_getNextNonce#
Returns the next nonce that should be used by the given account when sending a transaction.
Parameters#
BASE32
- address of the account.QUANTITY|TAG
- (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
QUANTITY
- integer of the next nonce that should be used by the given address.
Example#
cfx_sendRawTransaction#
Sends a signed transaction into the network for processing.
Parameters#
DATA
, the signed transaction data.
Returns#
DATA
, 32 Bytes - the transaction hash.
Example#
cfx_call#
Virtually calls a contract, returns the output data. The transaction will not be added to the blockchain.
Parameters#
Object
- a call request object:from
:BASE32
- (optional, default: random address) address of sender.to
:BASE32
- (optional, default:null
for contract creation) address of receiver.gasPrice
:QUANTITY
- (optional, default:0
) gas price provided by the sender in Drip.gas
:QUANTITY
- (optional, default:500000000
) gas provided by the sender.value
:QUANTITY
- (optional, default:0
) value transferred in Drip.data
:DATA
- (optional, default:0x
) the data send along with the transaction.nonce
:QUANTITY
- (optional, default:0
) the number of transactions made by the sender prior to this one.
QUANTITY|TAG
- (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
DATA
, Bytes - the output data, or an execution error.
Example#
cfx_estimateGasAndCollateral#
Virtually executes a transaction, returns an estimate for the size of storage collateralized and the gas used by the transaction. The transaction will not be added to the blockchain.
Parameters#
See cfx_call.
Returns#
Object
- an estimate result object:
gasLimit
:QUANTITY
- the recommended gas_limit.gasUsed
:QUANTITY
- gas used during execution.storageCollateralized
:QUANTITY
- size of storage collateralized, in bytes.
Example#
cfx_getLogs#
Returns logs matching the filter provided.
Parameters#
Object
- A log filter object:fromEpoch
:QUANTITY|TAG
- (optional, default:"latest_checkpoint"
) the epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter. Search will be applied from this epoch number.toEpoch
:QUANTITY|TAG
- (optional, default:"latest_state"
) the epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter. Search will be applied up until (and including) this epoch number.blockHashes
:Array
ofDATA
- (optional, default:null
) Array of up to 128 block hashes that the search will be applied to. This will override from/to epoch fields if it's notnull
.address
:Array
ofBASE32
- (optional, default:null
) Search contract addresses. Ifnull
, match all. If specified, the log must be produced by one of these contracts.topics
:Array
- (optional, default:null
) 32-byte earch topics. Logs can have4
topics: the event signature and up to3
indexed event arguments. The elements oftopics
match the corresponding log topics. Example:["0xA", null, ["0xB", "0xC"], null]
matches logs with"0xA"
as the 1st topic AND ("0xB"
OR"0xC"
) as the 3rd topic. Ifnull
, match all.limit
:QUANTITY
- (optional, default:null
) Ifnull
return all logs, otherwise should only return the lastlimit
logs. Note: if the node hasget_logs_filter_max_limit
set, it will overridelimit
if it isnull
or greater than the preset value.offset
:QUANTITY
- If specified, the response will skip thelast
offset logs. For instance, with 10 matching logs (0..9) and offset=0x1, limit=0x5, the response will contain logs 4..8. Note: Even if you specify offset, the corresponding logs still need to be processed by the node, so a filter with offset=10000, limit=10 has about the same performance as a filter with offset=0, limit=100010
Returns#
Array
- array of log objects corresponding to the matching logs:
address
:BASE32
- address of the contract that emitted the log.topics
:Array
ofDATA
- array of 32-byte event topics.data
:DATA
- data of log.blockHash
:DATA
- 32 Bytes - hash of the block containing the log.epochNumber
:QUANTITY
- epoch number of the block containing the log.transactionHash
:DATA
, 32 Bytes - hash of the transaction that created the log.transactionIndex
:QUANTITY
- transaction index in the block.logIndex
:QUANTITY
- log index in block.transactionLogIndex
:QUANTITY
- log index in transaction.
Example#
cfx_getTransactionReceipt#
Returns a transaction receipt, identified by the corresponding transaction hash.
Parameters#
DATA, 32 Bytes - hash of a transaction
Returns#
Object
- a transaction receipt object, or null
when no transaction was found or the transaction was not executed yet:
transactionHash
:DATA
, 32 Bytes - hash of the given transaction.index
:QUANTITY
- transaction index within the block.blockHash
:DATA
, 32 Bytes - hash of the block where this transaction was in and got executed.epochNumber
:QUANTITY
- epoch number of the block where this transaction was in and got executed.from
:BASE32
- address of the sender.to
:BASE32
- address of the receiver.null
when it is a contract deployment transaction.gasUsed
:QUANTITY
- gas used for executing the transaction.gasFee
:QUANTITY
- gas charged to the sender's account. If the provided gas (gas limit) is larger than the gas used, at most 1/4 of it is refunded.gasCoveredBySponsor
:Boolean
, true if this transaction's gas fee was covered by the sponsor.storageCollateralized
:QUANTITY
, the amount of storage collateral this transaction required.storageCoveredBySponsor
:Boolean
, true if this transaction's storage collateral was covered by the sponsor.storageReleased
:Array
, array of storage change objects, each specifying an address and the corresponding amount of storage collateral released, e.g.,[{ 'address': 'CFX:TYPE.USER:AARC9ABYCUE0HHZGYRR53M6CXEDGCCRMMYYBJGH4XG', 'collaterals': '0x280' }]
contractCreated
:BASE32
- address of the contract created.null
when it is not a contract deployment transaction.stateRoot
:DATA
, 32 Bytes - hash of the state root after the execution of the corresponding block.0
if the state root is not available.outcomeStatus
:QUANTITY
- the outcome status code.0x0
means success.0x1
means failed.0x2
means skippedlogsBloom
:DATA
, 256 Bytes - bloom filter for light clients to quickly retrieve related logs.logs
:Array
- array of log objects that this transaction generated, see cfx_getLogs.
Example#
cfx_getAccount#
Returns an account, identified by its address.
Parameters#
BASE32
- address of the account.QUANTITY|TAG
- (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
Object
- the state of the given account:
address
:BASE32
- address of the account.balance
:QUANTITY
- the balance of the account.nonce
:QUANTITY
- the nonce of the account's next transaction.codeHash
:DATA
- the code hash of the account.stakingBalance
:QUANTITY
- the staking balance of the account.collateralForStorage
:QUANTITY
- the collateral storage of the account.accumulatedInterestReturn
:QUANTITY
- accumulated interest return of the account.admin
:BASE32
- admin of the account.
Example#
cfx_getInterestRate#
Returns the interest rate at the given epoch.
Parameters#
QUANTITY|TAG
- (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
QUANTITY
- the interest rate at the given epoch.
Example#
cfx_getAccumulateInterestRate#
Returns the accumulate interest rate at the given epoch.
Parameters#
QUANTITY|TAG
- (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
QUANTITY
- the accumulate interest rate at the given epoch.
Example#
cfx_checkBalanceAgainstTransaction#
Check if a user's balance is enough to send a transaction with the specified gas and storage limits to the specified contract. The balance is enough if the user can cover the up-front payment of both execution and storage, or if these costs are sponsored by the contract.
Parameters#
BASE32
, account addressBASE32
, contract addressQUANTITY
, gas limitQUANTITY
, gas priceQUANTITY
, storage limitQUANTITY|TAG
, (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter.
Returns#
isBalanceEnough
:Boolean
- indicate balance is enoughwillPayCollateral
:Boolean
- false if the transaction is eligible for storage collateral sponsorship, true otherwise.willPayTxFee
:Boolean
- false if the transaction is eligible for gas sponsorship, true otherwise.
Example#
cfx_getSkippedBlocksByEpoch#
Returns the list of non-executed blocks in an epoch. By default, Conflux only executes the last 200 blocks in each epoch (note that under normal circumstances, epochs should be much smaller).
Parameters#
QUANTITY|TAG
- integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
Array
of block hashes
Example#
cfx_getConfirmationRiskByHash#
Returns the confirmation risk of a given block, identified by its hash.
Parameters#
DATA
, 32 Bytes - the block hash.
Returns#
QUANTITY
, the integer confirmation risk, ornull
if the block does not exist.
Example#
cfx_getStatus#
Returns the node status.
Parameters#
None.
Returns#
bestHash
:DATA
- hash of the latest epoch's pivot blockblockNumber
:QUANTITY
- total block numberchainId
:QUANTITY
- chainIdnetworkId
:QUANTITY
- networkIdepochNumber
:QUANTITY
- latest epoch numberlatestCheckpoint
:QUANTITY
- latest checkpoint epoch numberlatestConfirmed
:QUANTITY
- latest confirmed epoch numberlatestState
:QUANTITY
- latest state epoch numberpendingTxNumber
:QUANTITY
- current pending transaction count
Example#
cfx_clientVersion#
Returns the conflux-rust version.
Parameters#
None.
Returns#
STRING
- the client version
Example#
cfx_getBlockRewardInfo#
Returns the reward info for all executed blocks in the specified epoch.
Parameters#
QUANTITY|TAG
- integer epoch number, or the string"latest_checkpoint"
, see the epoch number parameter
Please note that reward calculation is delayed so it might not be available for the latest few epochs (including "latest_state"
).
Returns#
Array
- array of reward info objects
blockHash
:DATA
- the block hashauthor
:BASE32
- the address of block minertotalReward
:QUANTITY
- total reward of the block including base reward, tx fee, staking rewardbaseReward
:QUANTITY
- base rewardtxFee
:QUANTITY
- tx fee
Example#
cfx_getBlockByHashWithPivotAssumption#
Returns the requested block if the provided pivot hash is correct, returns an error otherwise.
Parameters#
DATA
, block hashDATA
, assumed pivot hashQUANTITY
, integer epoch number.
Returns#
See cfx_getBlockByHash.
Example#
Result see cfx_getBlockByHash.
cfx_getDepositList#
Returns the deposit list of the given account, identified by its address.
Parameters#
BASE32
- address of the account.QUANTITY|TAG
- (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
Array
- array of deposit info objects:
accumulatedInterestRate
:QUANTITY
- the accumulated interest rate at the time of the deposit.amount
:QUANTITY
- the number of tokens deposited.depositTime
:QUANTITY
- the time of the deposit.
Example#
cfx_getVoteList#
Returns the vote list of the given account, identified by its address.
Parameters#
BASE32
- address of the account.QUANTITY|TAG
- (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
Array
- array of vote info objects:
amount
:QUANTITY
- the number of tokens locked.unlockBlockNumber
:QUANTITY
- the block number at which the locked tokens are released.
For getting the current block number, please refer to conflux-rust#1973.
Example#
cfx_getSupplyInfo#
Returns summary supply info of the entire chain.
Parameters#
None.
Returns#
Object
- Object include the supply summary info.
totalIssued
:QUANTITY
- Amount of total issued CFX in DriptotalCollateral
:QUANTITY
- Amount of total storage collateraled CFX in DriptotalStaking
:QUANTITY
- Amount of total staking CFX in DriptotalCirculating
:QUANTITY
- Amount:TotalIssued
-FourYearUnlock
-TwoYearUnlock
Example#
cfx_getAccountPendingInfo#
Returns transaction pool pending info of one account
Parameters#
BASE32
- address of the account.
Returns#
Object
- Object include account's pending info.
localNonce
:QUANTITY
- User's transaction pool nonce that can be used for next transaction.pendingNonce
:QUANTITY
- User's current pending noncependingCount
:QUANTITY
- Count of pending transactionnextPendingTx
:DATA
- Hash of next pending transaction
Example#
cfx_getAccountPendingTransactions#
Returns pending transactions in pool of one account
Parameters#
BASE32
- address of the account.[
QUANTITY
] - Optional start nonce to return[
QUANTITY
] - Optionallimit
of pending transactions to return
Returns#
Object
- Object include account's pending transaction info.
firstTxStatus
:OBJECT
- An object with only one fieldpending
, it's value is the first pending transaction's status. Only have three casefutureNonce
,notEnoughCash
. Or just a stringready
pendingCount
:QUANTITY
- Count of pending transactionspendingTransactions
:ARRAY
- Array of pending transaction
Example#
cfx_getBlockByBlockNumber#
Returns information about a block, identified by its block number (block's tree-graph order number).
Added at#
Conflux-rust v1.1.5
Parameters#
QUANTITY
- the block number.Boolean
- iftrue
, it returns the full transaction objects. Iffalse
, only the hashes of the transactions are returned
Returns#
See cfx_getBlockByHash.
Example#
Result see cfx_getBlockByHash.
cfx_getPoSEconomics#
Returns PoS economics summary info.
Added at#
Conflux-rust v2.0.0
Parameters#
[
QUANTITY
] - (optional, default:"latest_state"
) integer epoch number, or the string"latest_state"
,"latest_confirmed"
,"latest_checkpoint"
or"earliest"
, see the epoch number parameter
Returns#
distributablePosInterest
:QUANTITY
Total distributable PoS interest (Unit is Drip)lastDistributeBlock
:QUANTITY
Last block that distributable PoS interesttotalPosStakingTokens
:QUANTITY
Total tokens staked in PoS (Unit is Drip)
Example#
cfx_openedMethodGroups#
Return fullnode's opened RPC method groups
Added at#
v2.0.0
Parameters#
None
Returns#
Method prefix array
Example#
cfx_getPoSRewardByEpoch#
returns the rewards information of a PoS epoch
Parameters#
QUANTITY
: epoch number
Returns#
accountRewards
:Array
of AccountRewardpowEpochHash
:HASH
- the hash value of the PoW block when the rewards are made
AccountReward#
posAddress
:ADDRESS
- PoS account addresspowAddress
:BASE32
- PoW account addressreward
:QUANTITY
- the number of rewards, in the unit of Drip
Example#
Request
Response
Last updated