CLI Sub-commands
Conflux CLI sub-commands is a collection of command line interfaces which allows you to interact with a local or remote Conflux node.
#
Manage Accountsaccount
sub-command allows you to manage accounts at local machine.
#
newCreate a new account at local machine.
#
Usage#
Example./conflux.exe account new
#
listList all accounts at local machine.
#
Usage#
Example./conflux.exe account list
#
importImport accounts from JSON UTC keystore files.
#
Usage#
Example./conflux.exe account import --import-path ./keystores
#
Public APIsPublic API allows you to interact with a local or remote Conflux node via HTTP connection in JSON-RPC protocol. All public APIs are under rpc
sub-command, and access to the JSON-RPC API at local machine with default url
option.
To access JSON-RPC API of remote Conflux node, please specify the correct --url
option (e.g. http://10.1.5.6:12537). By default, JSON-RPC is enabled only for local access for security consideration. You can manually enable remote access by configuring jsonrpc_http_port
in default.toml file.
All available commands are as following:
#
Get balance./conflux.exe rpc balance --address cfx:type.user:aarc9abycue0hhzgyrr53m6cxedgccrmmyybjgh4xg
#
Get nonce./conflux.exe rpc nonce --address cfx:type.user:aarc9abycue0hhzgyrr53m6cxedgccrmmyybjgh4xg
#
Get current epoch number./conflux.exe rpc epoch
#
Get block(s)- Get Best block hash:
./conflux.exe rpc best-block-hash
- Get block by epoch:
./conflux.exe rpc block-by-epoch --epoch latest_state
- Get block by height:
./conflux.exe rpc block-by-epoch --epoch 0x10
- Get blocks in epoch:
./conflux.exe rpc blocks --epoch latest_state
#
Get transaction./conflux.exe rpc tx --hash 0x718532fe76dbd8c4208c6c5a79588db35c0bf97e7d8a0faa5988ba66ad88b74c
#
Get receipt./conflux.exe rpc receipt --hash 0x718532fe76dbd8c4208c6c5a79588db35c0bf97e7d8a0faa5988ba66ad88b74c
#
Send signed transactionSend a signed transaction which encoded in HEX format. Generally, this API is used for Java-Script API to send encoded transaction. To send a transaction with CLI, suggest to use private API send transaction.
./conflux.exe rpc send --raw-bytes 0x...
#
Misc- Get contract code:
./conflux.exe rpc code --address cfx:type.contract:acc7uawf5ubtnmezvhu9dhc6sghea0403y2dgpyfjp
- Get recent mean gas price:
./conflux.exe rpc price
#
Private APIsPrivate API allows you to interact with local Conflux node only via HTTP connection in JSON-RPC protocol. Private APIs are provided for user to manage the local Conflux node, and requires the jsonrpc_local_http_port
configured in default.toml configuration file.
In addition, private APIs also helps developers to debug, test, and monitor the runtime of Conflux node.
All private APIs are under local
sub-command, and access to the JSON-RPC API at local machine with default url
option.
#
netnet
sub-command helps you to inspect the P2P network status.
#
Examples- List all connected P2P nodes:
./conflux.exe rpc local net session
- List a single P2P node:
./conflux.exe rpc local net session --id <node_id>
- Check network egress:
./conflux.exe rpc local net throttling
#
txpooltxpool
sub-command helps you to inspect the transaction pool.
#
Examples- List transaction pool status:
./conflux.exe rpc local txpool status
- List transactions in details:
./conflux.exe rpc local txpool content
- List summary of transactions:
./conflux.exe rpc local txpool inspect
- Inspect a transaction in detail:
./conflux.exe rpc local txpool inspect-one --hash <tx_hash>
#
sync-phaseGet the synchronization phase of local conflux node.
./conflux.exe rpc local sync-phase
#
Send transactionSend a transaction to local Conflux node.
#
Usage#
ExampleAlice transfer 5 Drip (1 CFX = 10^18 Drip) to Bob. Note, the address of Alice must exist at local machine, otherwise please create account for alice at first.
./conflux.exe rpc local send --from <alice_address> --to <bob_address> --value 0x5 --password 123456
Alice create a contract with gas 3,000,000. You can use solc to compile contract to get the bytecodes.
./conflux.exe rpc local send --from <alice_address> --value 0x0 --gas 0xâ€2DC6C0‬ --data <HEX_contract_bytecodes> --password 123456