Kaon CLI
The Kaon Command Line Interface (CLI) provides developers with direct access to the Kaon blockchain's functionality. This reference guide covers essential commands, usage, and practical applications.
Getting Started
Installation & Setup
The kaon-cli
tool is included with the Kaon node software. Before using these commands, ensure:
Your Kaon node is fully synced
You have proper permissions to execute CLI commands
Your wallet is properly configured and encrypted
Basic Syntax
All commands follow this general pattern:
For help with any command:
CLI Commands
abandontransaction
Mark in-wallet transaction as abandoned. This will mark this transaction and all its in-wallet descendants as abandoned which will allow for their inputs to be respent. It can be used to replace "stuck" or evicted transactions. It only works on transactions which are not included in a block and are not currently in the mempool. It has no effect on transactions which are already conflicted or abandoned.
Synopsis
Description
Marks a specific transaction and its descendants as abandoned within the wallet. This allows the inputs of the abandoned transactions to be reused in new transactions. This command is useful for dealing with transactions that are "stuck" or have been evicted from the mempool. It's important to note that this command only affects transactions that haven't been confirmed in a block and are not currently in the mempool. It won't have any effect on transactions that are already marked as conflicted or abandoned.
Arguments
txid
string
Yes
The ID of the transaction to abandon.
Flags
None
Input
The transaction ID ( txid
) as a string.
Output
None
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the transaction ID is invalid or doesn't exist in the wallet, an error message will be returned.
If the transaction is already confirmed in a block or is currently in the mempool, the command will have no effect and may return an error or a warning.
Notes
Use this command with caution. Once a transaction is abandoned, its outputs become spendable again, so ensure you understand the implications before using this command.
addmultisigaddress
Add a nrequired-to-sign multisignature address to the wallet. Each key is a Kaon address or hex-encoded public key. If 'account' is specified (DEPRECATED), assign address to that account.
Synopsis
Description
Adds a multisignature address to the wallet. This address requires nrequired
signatures from the provided list of keys to authorize spending. Each key can be a Kaon address or a hex-encoded public key. The optional account
parameter is deprecated and should not be used.
Arguments
nrequired
numeric
Yes
The number of required signatures.
keysobject
string
Yes
A JSON array of Kaon addresses or hex-encoded public keys.
account
string
No
DEPRECATED. An account to assign the address to (don't use).
Flags
None
Input
nrequired
: An integer representing the number of required signatures.keysobject
: A JSON string representing an array of Kaon addresses or hex-encoded public keys.account
: (Optional, deprecated) A string representing the account name.
Output
A Kaon address associated with the provided keys.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If
nrequired
is invalid (e.g., less than 1 or greater than the number of keys), an error is returned.If the
keysobject
is not a valid JSON array or contains invalid Kaon addresses or public keys, an error is returned.
Notes
Multisignature addresses enhance security by requiring multiple parties to authorize transactions.
addnode
Attempts add or remove a node from the addnode list. Or try a connection to a node once.
Synopsis
Description
Manages the list of nodes that the Kaon client attempts to connect to. You can use this command to add a new node, remove an existing node, or attempt a one-time connection to a specific node.
Arguments
node
string
Yes
The IP address and port of the node (e.g., "192.168.0.6:9871").
command
string
Yes
The action to perform: "add", "remove", or "onetry".
Flags
None
Input
node
: The IP address and port of the node as a string.command
: The command to execute ("add", "remove", or "onetry") as a string.
Output
None
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the
node
format is invalid, an error will be returned.If the
command
is not one of "add", "remove", or "onetry", an error will be returned.If attempting to add a node that is already in the addnode list, or remove a node that is not in the list, an error or warning may be returned.
Notes
The addnode
command affects the client's connection attempts but doesn't guarantee a successful connection. See getpeerinfo
for a list of currently connected peers. Related commands: getpeerinfo
, disconnectnode
.
autocombinerewards
Wallet will automatically monitor for any coins with value below the threshold amount, and combine them if they reside with the same Kaon address. When autocombinerewards runs it will create a transaction, and therefore will be subject to transaction fees.
Synopsis
Description
Enables or disables the automatic combining of small coin outputs within the wallet. If enabled, the wallet will regularly check for outputs below the specified threshold
and combine them into a single larger output. This helps to reduce the number of UTXOs in the wallet and can improve transaction efficiency. Note that combining outputs involves creating a new transaction, which incurs transaction fees.
Arguments
enable
boolean
Yes
Enable (true) or disable (false) automatic combining.
threshold
numeric
No
The minimum output value below which coins will be combined.
Flags
None
Input
enable
: A boolean value (true
orfalse
).threshold
: (Optional) A numeric value representing the threshold. Defaults to 0.
Output
None
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If
enable
is not a valid boolean, an error will be returned.If
threshold
is not a valid number, an error will be returned.
Notes
Transaction fees are deducted from the combined output. Combining outputs can help improve wallet performance, especially if you have many small UTXOs.
backupwallet
Safely copies wallet.dat to destination, which can be a directory or a path with filename.
Synopsis
Description
Creates a backup of the wallet data file ( wallet.dat
). This backup can be used to restore the wallet in case of data loss or corruption. The destination
can be either a directory or a full file path.
Arguments
destination
string
Yes
The directory or file path for the wallet backup.
Flags
None
Input
destination
: A string representing the backup destination.
Output
None
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the destination directory doesn't exist or is not writable, an error will be returned.
If the wallet file cannot be read, an error will be returned.
Notes
Regularly backing up your wallet is essential for protecting your funds. Store backups securely and in multiple locations. Related commands: dumpwallet
, importwallet
bip38decrypt
Decrypts and then imports password protected private key.
Synopsis
Description
Decrypts a BIP38-encrypted private key and imports it into the wallet. BIP38 encryption provides a secure way to store private keys by encrypting them with a passphrase.
Arguments
kaonaddress
string
Yes
The encrypted private key.
passphrase
string
Yes
The passphrase to decrypt the key.
Flags
None
Input
kaonaddress
: The encrypted BIP38 private key as a string.passphrase
: The passphrase used to encrypt the private key as a string.
Output
The decrypted private key.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the encrypted key is invalid or not a valid BIP38-encrypted key, an error message will be returned.
If the passphrase is incorrect, decryption will fail, and an error will be returned.
Notes
After decrypting and importing the key, you can use it like any other private key in your wallet. Be sure to keep the decrypted private key secure. Related commands: bip38encrypt
, importprivkey
, dumpprivkey
bip38encrypt
Encrypts a private key corresponding to 'kaonaddress'.
Synopsis
Description
Encrypts a private key corresponding to a specific Kaon address using BIP38 encryption. This allows you to securely store your private keys by protecting them with a passphrase. This command only works if you already hold the private key for the specified address in your wallet.
Arguments
kaonaddress
string
Yes
The Kaon address associated with the key.
passphrase
string
Yes
The passphrase to encrypt the key with.
Flags
None
Input
kaonaddress
: The Kaon address for the private key to encrypt.passphrase
: The passphrase to use for encryption. Valid special chars: !#$%&'()*+, -./:; <=>?`{|}~
Output
The BIP38 encrypted private key.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the address is invalid or doesn't exist in the wallet, an error is returned.
If the wallet doesn't hold the private key for the specified address, an error is returned.
Notes
Store the encrypted private key securely. You will need the passphrase to decrypt and use the key later. Related commands: bip38decrypt
, importprivkey
, dumpprivkey
callcontract
Call contract methods offline.
Synopsis
Description
Calls a contract method offline, allowing you to test and debug contract interactions without broadcasting a transaction to the network. This command provides detailed information about the execution result and transaction receipt, including gas usage, returned data, and any exceptions thrown.
Arguments
address
string
Yes
The contract address (hexadecimal).
data
string
Yes
The data hex string to pass to the contract method.
senderAddress
string
No
The sender address string.
gasLimit
numeric
No
The gas limit for executing the contract.
amount
numeric
No
UNUSED The amount in KAON to send. eg 0.1, default: 0
Flags
None
Input
address
: The contract address as a hexadecimal string.data
: The data to send to the contract method as a hexadecimal string.senderAddress
: (Optional) The sender's Kaon address.gasLimit
: (Optional) The gas limit for the contract execution.amount
: (Optional, UNUSED) The amount of KAON to send (default: 0).
Output
A JSON object containing the execution result and transaction receipt.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the contract address is invalid, an error is returned.
If the data hex string is invalid, an error is returned.
If the gas limit is insufficient, an error is returned.
If the contract execution throws an exception, the
excepted
field in the output will contain the exception message.
Notes
This command is helpful for testing contract functionality before deploying it or sending transactions on the mainnet. It simulates a transaction without actually broadcasting it.
checkbudgets
Initiates a budget check cycle manually.
Synopsis
Description
Manually triggers a budget check cycle. This cycle evaluates budget proposals and determines which proposals will be funded in the next payment cycle.
Arguments
None
Flags
None
Input
None
Output
None
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
Any errors encountered during the budget check cycle will be logged.
Notes
Manually checking budgets can be useful for testing or debugging the budget system. Related commands: getbudgetinfo
, getbudgetprojection
, getbudgetvotes
, preparebudget
, submitbudget
clearbanned
Clear all banned IPs.
Synopsis
Description
Removes all IP addresses and subnets from the ban list. Banned IPs are prevented from connecting to your Kaon node.
Arguments
None
Flags
None
Input
None
Output
None
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
Any errors encountered while clearing the ban list will be logged.
Notes
Use with caution, as clearing the ban list might allow previously banned nodes to reconnect. Related commands: setban
, listbanned
createcontract
Create a contract with bytecode.
Synopsis
Description
Creates a new smart contract on the Kaon blockchain using the provided bytecode. This command allows you to deploy your own smart contracts and interact with them. You can specify gas limit, gas price, sender address, whether to broadcast the transaction, and whether to return the change to the sender.
Arguments
bytecode
string
Yes
The contract bytecode (hexadecimal string).
gasLimit
numeric
No
The gas limit for contract creation (default: DEFAULT_GAS_LIMIT_OP_CREATE).
gasPrice
numeric
No
The gas price in KAON per gas unit.
senderaddress
string
No
The Kaon address used to create the contract.
broadcast
boolean
No
Whether to broadcast the transaction (default: true).
changeToSender
boolean
No
Return change to the sender (default: true).
Flags
None
Input
bytecode
: Contract bytecode as a hexadecimal string.gasLimit
: (Optional) Gas limit as a number. Defaults to DEFAULT_GAS_LIMIT_OP_CREATE.gasPrice
: (Optional) Gas price in KAON per gas unit.senderaddress
: (Optional) Sender's Kaon address.broadcast
: (Optional) Boolean indicating whether to broadcast the transaction. Defaults to true.changeToSender
: (Optional) Boolean indicating whether to return change to the sender. Defaults to true.
Output
A JSON array containing the transaction details:
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the bytecode is invalid, an error is returned.
If the gas limit is insufficient, an error is returned.
If the sender address is invalid or doesn't have enough balance, an error is returned.
If broadcasting the transaction fails, an error is returned.
Notes
Contract creation consumes KAON for gas. Ensure that the sender address has sufficient balance and the gas limit and price are appropriately set. Relatd commands: sendtocontract
, callcontract
, listcontracts
, getaccountinfo
, getstorage
createmasternodebroadcast
Creates a masternode broadcast message for one or all masternodes configured in masternode.conf.
Synopsis
Description
Generates a masternode broadcast message, which is necessary for announcing a masternode to the network. You can create a broadcast for a single masternode using its alias or for all masternodes defined in your masternode.conf
file.
Arguments
command
string
Yes
The command to execute: "alias" for a single masternode or "all" for all.
alias
string
Yes (if command is "alias")
The alias of the masternode (defined in masternode.conf).
Flags
None
Input
command
: A string, either "alias" or "all".alias
: (Optional, required if command is "alias") A string representing the masternode alias.
Output
If
command
is "all": A JSON object with an overall status message and an array of broadcast objects, each containing details about the broadcast for a specific masternode.
If
command
is "alias": A JSON object containing the broadcast details for the specified masternode.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the command is not "alias" or "all", an error is returned.
If "alias" is specified but the alias doesn't exist in the configuration, an error is returned.
If any error occurs during the broadcast creation for a specific masternode, the "success" field for that masternode will be false, and an "error_message" will be provided.
Notes
This command doesn't start the masternode; it only creates the broadcast message. You'll need to use other commands like startmasternode
to actually start the masternode. Related commands: startmasternode
, decodemasternodebroadcast
, relaymasternodebroadcast
, listmasternodes
createmasternodekey
Create a new masternode private key.
Synopsis
Description
Generates a new private key specifically for use with a masternode. This key is crucial for running a masternode and should be kept securely.
Arguments
None
Flags
None
Input
None
Output
The newly generated masternode private key.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the key generation process encounters any errors, an error message will be returned.
Notes
Store this private key securely, as losing it can result in the loss of your masternode collateral. This key is different from your regular wallet private keys and shouldn't be used for other purposes. Related commands: startmasternode
, listmasternodes
createmasternodev2
Attempts to start one or more masternode(s). 1) send a tx with 10k to that address. 2) get the rate output. 3) use those values on the masternode.conf.
Synopsis
Description
This command attempts to start a masternode by sending a transaction with the specified amount (10, 000 KAON) to the specified address. It then retrieves the transaction output and uses those values to configure the masternode in the masternode.conf
file.
Arguments
privkey
string
Yes
The masternode's private key.
alias
string
Yes
The alias for the masternode.
address
string
Yes
IP address and port of the masternode.
Flags
None
Input
privkey
: The private key of the masternode.alias
: The alias or label for the masternode.address
: The IP address and port of the masternode.
Output
A JSON object indicating the status of the operation.
Examples
CLI Usage:
JSON-RPC Call (example - structure depends on the actual output):
Error Handling
If any of the arguments are invalid or missing, an error message will be returned.
If the transaction fails to send or the output cannot be retrieved, an error message will be returned.
If the
masternode.conf
file cannot be updated, an error message will be returned.
Notes
This command automates the process of setting up a masternode, but it's important to understand the underlying steps involved. Ensure you have the correct collateral amount (10, 000 KAON) and that the specified address is controlled by your wallet. Related commands: startmasternode
, listmasternodes
createmultisig
Creates a multi-signature address with n signature of m keys required. It returns a json object with the address and redeemScript.
Synopsis
Description
Creates a multisignature address that requires a specific number of signatures ( nrequired
) to authorize spending. The address is generated from a list of provided public keys or Kaon addresses ( keys
). The command returns the newly created multisignature address and its corresponding redeem script.
Arguments
nrequired
numeric
Yes
The number of required signatures.
keys
string
Yes
A JSON array of Kaon addresses or hex-encoded public keys.
Flags
None
Input
nrequired
: An integer representing the minimum number of signatures required.keys
: A JSON string representing an array of Kaon addresses or hex-encoded public keys.
Output
A JSON object containing the multisignature address and redeem script.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the
nrequired
parameter is invalid (e.g., less than 1 or greater than the number of keys), an error is returned.If any of the keys in the
keys
array are invalid, an error is returned.
Notes
Multisignature addresses enhance security by requiring multiple parties to authorize transactions. The redeem script is essential for spending funds from this address. Related commands: addmultisigaddress
createwallet
Creates and loads a new wallet. Note that this will shutdown the server.
Synopsis
Description
Creates a new Kaon wallet. This action will shut down the current Kaon server. The parameters wallet_name
, disable_private_keys
, blank
, avoid_reuse
, descriptors
, load_on_startup
and external_signer
are currently unused. You can specify a passphrase to encrypt the new wallet.
Arguments
wallet_name
string
No
UNUSED
disable_private_keys
boolean
No
UNUSED
blank
boolean
No
UNUSED
passphrase
string
No
The passphrase to encrypt the wallet with. It must be at least 1 character, but should be long.
avoid_reuse
boolean
No
UNUSED
descriptors
boolean
No
UNUSED
load_on_startup
boolean
No
UNUSED
external_signer
boolean
No
UNUSED
Flags
None
Input
passphrase
: (Optional) The passphrase to encrypt the new wallet.
Output
None
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the wallet creation fails (e.g., due to insufficient disk space or an invalid passphrase), an error message will be displayed, and the server will not shut down.
Notes
After creating a new wallet, you'll need to restart the Kaon server. If you provided a passphrase, you'll need to unlock the wallet using the walletpassphrase
command before performing any transactions. Related commands: encryptwallet
, walletpassphrase
, walletlock
decodemasternodebroadcast
Command to decode masternode broadcast messages.
Synopsis
Description
Decodes a hex-encoded masternode broadcast message. This command is useful for inspecting the contents of a broadcast message, such as the masternode's IP address, public keys, and signature.
Arguments
hexstring
string
Yes
The hex-encoded masternode broadcast message.
Flags
None
Input
hexstring
: The hexadecimal representation of the masternode broadcast message.
Output
A JSON object containing the decoded information from the broadcast message.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the input hexstring
is not a valid masternode broadcast message, an error will be returned.
Notes
The decoded information helps verify the authenticity and validity of the broadcast message. Related commands: createmasternodebroadcast
, relaymasternodebroadcast
decoderawtransaction
Return a JSON object representing the serialized, hex-encoded transaction.
Synopsis
Description
Decodes a raw transaction given its hexadecimal representation. This command provides a structured JSON representation of the transaction, including details about its inputs, outputs, and other relevant information. The iswitness
parameter is unused because Kaon always uses SegWit.
Arguments
hex
string
Yes
The transaction hex string.
iswitness
boolean
Yes
UNUSED (Kaon always uses SegWit).
Flags
None
Input
hex
: The raw transaction as a hexadecimal string.iswitness
: A boolean value (always treat as true for Kaon).
Output
A JSON object representing the decoded raw transaction. See the original documentation for the detailed structure of this object. It includes details such as transaction ID, size, version, inputs, outputs, and involved addresses.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the input hex
string is not a valid transaction, an error will be returned.
Notes
This command is helpful for understanding the structure and contents of a raw transaction. Related commands: createrawtransaction
, signrawtransactionwithkey
, sendrawtransaction
decodescript
Decode a hex-encoded script.
Synopsis
Description
Decodes a hex-encoded script and returns information about its structure and function. This command is helpful for understanding the details of a script, such as the type of script, the required signatures, and involved addresses.
Arguments
hex
string
Yes
The hex-encoded script.
Flags
None
Input
hex
: A hexadecimal string representing the script.
Output
A JSON object with the decoded script information, including the assembly code, type, required signatures, and associated addresses.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the input hex
is not a valid script, an error message will be returned.
Notes
This command is valuable for analyzing the details of scripts used in transactions.
delegatestake
Delegate an amount to a given address for cold staking. The amount is a real and is rounded to the nearest 0.00000001.
Synopsis
Description
Delegates a specified amount of KAON to a staking address for cold staking. Cold staking allows you to earn staking rewards without keeping your coins online. The optional owneraddress
specifies the address that can spend the staking rewards. If not provided, a new address is generated. fExternalOwner
allows you to use an owneraddress
even if it's not in your wallet. fUseDelegated
allows the use of already delegated inputs if needed, and fForceNotEnabled
forces the creation even if cold staking is disabled (for testing).
Arguments
stakingaddress
string
Yes
The Kaon staking address to delegate to.
amount
numeric
Yes
The amount to delegate.
owneraddress
string
No
The Kaon address that can spend the staking rewards.
fExternalOwner
boolean
No
Use the provided owneraddress
even if it's not in your wallet (default: false).
fUseDelegated
boolean
No
Include already delegated inputs if needed (default: false).
fForceNotEnabled
boolean
No
Force stake delegation even if it's disabled (default: false, use for testing purposes only).
Flags
None
Input
See Arguments description. Amounts are in KAON.
Output
A JSON object containing the delegation details.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the
stakingaddress
orowneraddress
are invalid, an error is returned.If the amount is insufficient or exceeds the available balance, an error is returned.
If cold staking is disabled and
fForceNotEnabled
is not set, an error is returned.
Notes
Cold staking allows for offline staking, enhancing security. The delegator retains ownership of the delegated funds. Related commands: rawdelegatestake
, getcoldstakingbalance
, listcoldutxos
delegatoradd
Add the provided address into the allowed delegators AddressBook. This enables the staking of coins delegated to this wallet, owned by .
Synopsis
Description
Adds a delegator address to the whitelist, allowing the wallet to stake coins delegated from that address. This is necessary for cold staking scenarios where the owner of the funds delegates staking rights to another address. An optional label can be added for better organization.
Arguments
addr
string
Yes
The Kaon address to whitelist.
label
string
No
A label for the whitelisted address (optional).
Flags
None
Input
addr
: The delegator's Kaon address as a string.label
: (Optional) A descriptive label for the address.
Output
true
if the address was successfully added.false
otherwise.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the provided address is invalid, an error is returned.
If the address is already whitelisted, an error or warning may be returned.
Notes
Adding a delegator to the whitelist enables cold staking for their delegated funds. Related commands: delegatorremove
, listdelegators
, delegatestake
delegatorremove
Updates the provided address from the allowed delegators keystore to a "delegable" status. This disables the staking of coins delegated to this wallet, owned by .
Synopsis
Description
Removes a delegator address from the whitelist, preventing the wallet from staking coins delegated from that address. This is the reverse of delegatoradd
.
Arguments
addr
string
Yes
The address to remove from whitelist.
Flags
None
Input
addr
: The delegator's Kaon address to remove.
Output
true
if the address was successfully removed.false
otherwise.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the provided address is invalid, an error will be returned.
If the address is not currently whitelisted, a warning or error may be returned.
Notes
Removing a delegator disables cold staking for their delegated UTXOs held by this wallet. Related commands: delegatoradd
, listdelegators
, delegatestake
disconnectnode
Immediately disconnects from the specified node.
Synopsis
Description
Disconnects from a specific peer node. This is useful for troubleshooting network issues or manually managing connections to other nodes on the network.
Arguments
node
string
Yes
The node's IP address and port.
Flags
None
Input
The IP address and port of the node to disconnect from (e.g., "192.168.0.6:8333").
Output
None
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the specified node is not connected, an error or warning may be returned.
If the node address is invalid, an error will be returned.
Notes
Disconnecting a node may temporarily affect network connectivity and synchronization. Related commands: addnode
, getpeerinfo
dumpprivkey
Reveals the private key corresponding to 'kaonaddress'. Then the importprivkey can be used with this output.
Synopsis
Description
Retrieves and displays the private key associated with a specified Kaon address. This command is extremely sensitive as it exposes the private key, which controls access to the funds associated with that address. Use with extreme caution and only when absolutely necessary. It's essential to ensure no unauthorized individuals or processes can access the output of this command.
Arguments
kaonaddress
string
Yes
The Kaon address for which to retrieve the key.
Flags
None
Input
The Kaon address.
Output
The private key corresponding to the specified Kaon address.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the provided address is not valid or not found in the wallet, an error is returned.
If the wallet is encrypted and not unlocked, an error is returned.
Notes
Security Warning: Handle the output of this command with utmost care. Anyone with access to the private key has control over the funds associated with the corresponding Kaon address. Related commands: importprivkey
, bip38encrypt
dumpwallet
Dumps all wallet keys in a human-readable format.
Synopsis
Description
Exports all private keys from the wallet to a file in a human-readable format. This command is highly sensitive and should be used with extreme caution. The exported file contains all the information needed to control the funds associated with the wallet, so it's crucial to store it securely and protect it from unauthorized access.
Arguments
filename
string
Yes
The name of the output file.
Flags
None
Input
filename
: The name of the file where the wallet data will be written.
Output
None (The output is written to the specified file.)
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the file cannot be created or written to (e.g., due to permissions issues or disk space), an error is returned.
If the wallet is encrypted and not unlocked, an error is returned.
Notes
Security Warning: The file generated by this command contains highly sensitive information. Securely store the backup and protect it from unauthorized access. Never share this file with anyone. Related commands: importwallet
, backupwallet
encryptwallet
Encrypts the wallet with 'passphrase'. This is for first time encryption. After this, any calls that interact with private keys such as sending or signing will require the passphrase to be set prior the making these calls. Use the walletpassphrase call for this, and then walletlock call. If the wallet is already encrypted, use the walletpassphrasechange call. Note that this will shutdown the server.
Synopsis
Description
Encrypts the wallet using the provided passphrase. This is a crucial security measure to protect your funds. Once encrypted, any command that requires access to private keys (such as sending transactions or signing messages) will require you to unlock the wallet first using the walletpassphrase
command. This command will shut down the server after encrypting the wallet.
Arguments
passphrase
string
Yes
The passphrase to use for wallet encryption.
Flags
None
Input
passphrase
: The encryption passphrase as a string. Must be at least one character long, but stronger, longer passphrases are highly recommended.
Output
None
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the wallet is already encrypted, an error is returned.
If the passphrase is invalid or empty, an error is returned.
Notes
After encrypting the wallet, you'll need to restart the Kaon server. Remember your passphrase, as losing it means losing access to your funds. Related commands: walletpassphrase
, walletlock
, walletpassphrasechange
, createwallet
estimatefee
Estimates the approximate fee per kilobyte needed for a transaction to begin confirmation within nblocks blocks.
Synopsis
Description
Estimates the transaction fee per kilobyte required for a transaction to be confirmed within a specified number of blocks ( nblocks
). This helps you determine an appropriate fee to include with your transactions to ensure timely confirmation.
Arguments
nblocks
numeric
Yes
The number of blocks within which to confirm the transaction.
Flags
None
Input
nblocks
: A number of blocks for fee estimation.
Output
The estimated fee per kilobyte, or -1.0 if there is insufficient data to make an estimate.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the nblocks
parameter is invalid, an error may be returned.
Notes
The estimate is based on historical transaction data and network conditions, so it's not guaranteed to be accurate. A value of -1.0 indicates that the node hasn't observed enough transactions to provide a reliable estimate.
estimatepriority
Estimates the approximate priority a zero-fee transaction needs to begin confirmation within nblocks blocks.
Synopsis
Description
Estimates the priority required for a zero-fee transaction to be confirmed within a given number of blocks ( nblocks
). Transaction priority is calculated based on factors like coin age and transaction size. This command is generally less relevant with modern fee estimation mechanisms.
Arguments
nblocks
numeric
Yes
The number of blocks for confirmation time estimation.
Flags
None
Input
nblocks
: The target number of blocks for confirmation.
Output
The estimated priority value. Returns -1.0 if insufficient data prevents estimation.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the input nblocks
value is invalid, an error may be returned.
Notes
The estimate is based on recent transactions and may not be accurate. The returned value of -1.0 signifies insufficient data for a reliable estimate. Zero-fee transactions are generally discouraged on the Kaon network as they are unlikely to be confirmed in a timely manner.
fromhexaddress
Converts a raw hex address to a base58 pubkeyhash address.
Synopsis
Description
Converts a hexadecimal representation of a Kaon address to its base58 encoded format. This is useful when dealing with raw addresses in scripts or smart contracts and needing their standard, user-friendly representation.
Arguments
hexaddress
string
Yes
The raw hexadecimal address.
Flags
None
Input
hexaddress
: The hexadecimal address string.
Output
The base58 encoded pubkeyhash address.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the input is not a valid hexadecimal string or represents an invalid Kaon address, an error will be returned.
Notes
This function is the reverse of gethexaddress
. Related commands: gethexaddress
, validateaddress
gasprice
Returns the current gas price.
Synopsis
Description
Retrieves the current price of gas in KAON. Gas is required to execute smart contracts on the Kaon network. The gas price determines the cost of each unit of gas used during contract execution.
Arguments
None
Flags
None
Input
None
Output
The current gas price as a numeric value.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
Any errors encountered while retrieving the gas price will be logged. However, it's rare for this command to return an error.
Notes
The gas price can fluctuate based on network demand. Related commands: createcontract
, sendtocontract
generate
Mine blocks immediately (before the RPC call returns). Note: this function can only be used on the regtest network.
Synopsis
Description
Generates (mines) a specified number of blocks on the regtest network. This command is intended for testing and development purposes only and should not be used on mainnet or testnet.
Arguments
nGenerate
numeric
Yes
The number of blocks to mine.
Flags
None
Input
nGenerate
: An integer specifying the number of blocks to generate.
Output
An array of hexadecimal block hashes representing the generated blocks.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
This command will return an error if used on mainnet or testnet.
If the requested number of blocks cannot be generated, an error will be returned.
Notes
This command is exclusively for testing and development on the regtest network. Using it on mainnet or testnet will have no effect and might return an error.
generatetoaddress
Mine blocks immediately to a specified address (before the RPC call returns).
Synopsis
Description
Mines a specified number of blocks and sends the mining rewards to a given address. This command is primarily for testing and development purposes. The address
parameter is unused, and the maxtries
parameter is also unused.
Arguments
nblocks
numeric
Yes
The number of blocks to generate.
address
string
Yes
UNUSED. The address to send rewards to (ignored).
maxtries
numeric
No
UNUSED. (Ignored).
Flags
None
Input
nblocks
: The number of blocks to generate.address
: UNUSED - Provide a valid Kaon address (but it's ignored).maxtries
: UNUSED
Output
An array of string hashes of the generated blocks.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the
nblocks
parameter is invalid, an error will be returned.
Notes
While you can specify an address, the mining rewards will not be sent to that address (this parameter is ignored). This command is primarily intended for testing and development. Related commands: getnewaddress
, generate
getaccount
DEPRECATED. Returns the account associated with the given address.
Synopsis
Description
DEPRECATED. This command is deprecated and should not be used. It was previously used to retrieve the account name associated with a specific Kaon address. Account functionality is generally deprecated in newer versions of Kaon.
Arguments
kaonaddress
string
Yes
The Kaon address for lookup.
Flags
None
Input
kaonaddress
: The Kaon address as a string.
Output
The account name associated with the address (if any), or an error if the address is invalid or not associated with an account.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the input address is invalid, doesn't exist, or no account is associated with it, an error message is returned.
Notes
This command is deprecated and shouldn't be used in new code. Avoid using accounts in your Kaon applications.
getaccountaddress
DEPRECATED. Returns the current Kaon address for receiving payments to this account.
Synopsis
Description
DEPRECATED. This command is deprecated and should not be used. In older versions of Kaon, this command returned a Kaon address associated with a specific account. If the account didn't exist, it would be created along with a new address. Account functionality is deprecated in newer versions of Kaon.
Arguments
account
string
Yes
The account name. Can be "" for the default account.
Flags
None
Input
The account name. Can be an empty string "" for the default account.
Output
The Kaon address associated with the specified account.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
Errors can occur if the account name is invalid.
Notes
This command is deprecated and should not be used. Avoid using account-related functionalities in newer Kaon applications. Consider using getnewaddress
instead to generate fresh addresses. Related commands: getnewaddress
, setaccount
, getaccount
, getaddressesbyaccount
getaccountinfo
Get contract details including balance, storage data and code.
Synopsis
Description
Retrieves detailed information about a smart contract account, including its balance, storage data, and bytecode. This command provides insights into the state and functionality of a deployed smart contract.
Arguments
address
string
Yes
The contract address.
Flags
None
Input
address
: The address of the smart contract.
Output
A JSON object containing contract details.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the provided contract address is invalid, or if the contract doesn't exist, an error will be returned.
Notes
This command is helpful for inspecting the current state of a smart contract. Related commands: createcontract
, sendtocontract
, callcontract
, listcontracts
getaddednodeinfo
Returns information about the given added node, or all added nodes (note that onetry addnodes are not listed here). If dns is false, only a list of added nodes will be provided, otherwise connected information will also be available.
Synopsis
Description
Returns information about nodes added using the addnode
command. The dns
parameter controls whether to resolve the node's hostname. If dns
is true, the command will attempt to resolve the hostname and provide connection information. If dns
is false, only the added node IP addresses/hostnames will be listed. The optional node
parameter allows retrieval of information for a specific node. If omitted, information for all added nodes is returned.
Arguments
dns
boolean
Yes
Whether to look up the DNS info for the node.
node
string
No
The node to get information about (optional). If omitted, returns data for all added nodes.
Flags
None
Input
dns
: Boolean value (true/false).node
: (Optional) IP address or hostname of the node.
Output
A JSON array containing information about each added node.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If an invalid
node
parameter is provided, an error message will be returned.
Notes
The information provided includes the added node, connection status, and addresses if a connection exists. Related commands: addnode
, getpeerinfo
getaddressbalance
Returns the balance for an address(es) (requires addressindex to be enabled).
Synopsis
Description
Returns the balance for one or more addresses. Requires the addressindex
to be enabled. This command provides the balance, total received, and immature balance for the given addresses.
Arguments
argument
object
Yes
A JSON object with an "addresses" array of Kaon addresses.
Flags
None
Input
A JSON object with the following format:
Output
A JSON object with the balances for the given addresses.
Examples
CLI Usage:
JSON-RPC Call:
Error Handling
If the addressindex is not enabled, the command returns an error.
If any provided address is invalid, the command might return an error or exclude the invalid address from the results.
Notes
The balance information is specific to the provided addresses. Ensure that the addressindex
is enabled to use this command. Related commands: getaddressutxos
, getreceivedbyaddress
getaddressesbyaccount
DEPRECATED. Returns the list of addresses for the given account.
Synopsis
Description
DEPRECATED. Returns a list of addresses associated with a given account. Account functionality is deprecated and should not be used in new code. This command is provided for backward compatibility.
Arguments
account
string
Yes
The account name.
Flags
None
Input
account
: The name of the account.
Output
A JSON array of Kaon addresses associated with the account.
Examples
CLI Usage: