Node API Reference
Last updated
Was this helpful?
Last updated
Was this helpful?
The JSON-RPC API can be consumed through different transports: TCP, HTTP and Websockets. The node operator can enable or disable the JSON-RPC service, as well as specify a different network address for each transport in the node's configuration file. By default, the tcp
port is set to be 21338, http
to 21339 and the ws
to 21340.
Sensitive methods are those that either use the node's master key or provide information that may compromise the node's public key or address, or even the node's private key itself.
Sensitive methods allow node operators to easily manage their own nodes from a command line interface within the same host or private network. By default, sensitive methods are enabled.
When exposing any of the JSON-RPC ports (tcp/21388, http/21339, ws/21340) to a public IP, ensure to disable sensitive methods first by setting enable_sensitive_methods = false
in your node's witnet.toml configuration file.
Public methods provide information that do not compromise node's private information, like its private or public key, or address:
Add one or more peer addresses to the list of available ones.
Vec<SocketAddr>
true
Create a stake authorization for the given address.
Clear all peers from the list of available ones.
None.
true
Create a VRF proof for the provided message with the stored key.
Vec<u8>
Vec<u8>
Show information about a data request.
drTxHash
: Data request transaction hash.
Get the balance of a the pkh
.
pkh
: The public key hash to get the balance from.
simple?
: Distinguish between fetching a simple balance or fetching confirmed and unconfirmed balance. Defaults to `false`.
Get detailed information about a block being queried by its hash.
blockHash
: The hash of the block must be provided as a hexadecimal string.
metadata
: (Optional) If set to true, transactions metadata will be provided.
Get the list of all the known block hashes.
epoch
: (Optional) First epoch for which to return block hashes. If the provided value is negative, it returns block hashes from the last n epochs. Default to 0.
limit
: (Optional) Number of block hashes to return. If the provided value is negative, return the last n block hashes from this epoch range. If the value is zero, it's unlimited. Default to 0.
Vec<u32, Hash>
: An array of epochs and block hashes.
Get consensus constants used by the node.
None
Get all the pending transactions.
None
Get the public key of the node.
None
[u8; 33]
Get public address of the node.
None
String
Displays the reputation score associated with a given public address and its eligibility to mine a block.
pkh
: The Witnet public address.
Get all the nodes active and their elegibility. It also lists the nodes with reputation grater than 0 but not active, if any.
None.
Get the blocks that pertain to the superblock specified.
Map including one only of these:
block_epoch
: Superblock epoch.
superblock_index
: Superblock index.
Get supply information.
None
Get detailed information about a transaction being queried by its hash.
txHash
: It should be provided as a hexadecimal string.
Get unspent transaction outputs belonging to given public address.
pkh
: Public address.
Get the list of peer addresses known to the node.
None
A list with the address of the peer and the type which can be new
or tried
.
None
true
Make the node process, validate and potentially broadcast a new inventory entry.
true
if no errors.
Get stats info from node.
None
Export the private key associated with the node identity in XPRV format.
None
String
: Private key in XPRV format.
List inbound and outbound connections currently established by the node. Outbound connections are those initiated on our side, and inbound connections are those that were initiated by peer nodes. A node that does not announce a public address (IP and port) will normally have no inbound connections, as there is no way for other nodes to discover a valid network route to it.
None
Get priority and time-to-block estimations for different priority tiers.
None
priority
: priority value in nanowits per weight unit.
time_to_block
: average for your transaction to be included in a block in seconds.
Get information about protocol versions and which version is currently being enforced.
None
Query amount of nanowits staked by an address or get all stake entries in the network.
Parameters
Returns
Example
Delete the chain state until the specified epoch and resync from there.
Epoch: u32
true
Create and broadcast a data request transaction to the Witnet Network.
Create and broadcast a value transfer transaction. That is, send some amount of wit coins from the node's own balance into a different Witnet address.
Sign a piece of data with the node's master key.
[u8; 32]
Get consolidated and on-going upgrades of the Witnet network.
None
Create and broadcast a stake transaction to the Witnet Network.
Parameters
Returns
Example
Get node synchronization status.
None
WaitingConsensus
: waiting for reaching consensus between its peers
Synchronizing
: synchronization process.
AlmostSynced
: it has all the blocks in the chain and is ready to start consolidating block candidates in real time.
Synced
: can consolidate block candidates, propose its own candidates (mining) and participate in resolving data requests (witnessing).
Ask your node to resolve data request locally, without actually broadcasting it to the Witnet network.
Create and broadcast an unstake transaction to the Witnet Network.
Vec<
>
Initialize all known peers present in .
Accepts the JSON serialization of a well-formed or .
Vec<
>
: A map whose keys represent the different levels of priority for data requests transactions and value transfer transactions: stinky, low, medium, high and opulent. The value is a map which includes:
Option<>
: Map with the chain beacon, the current epoch and the state of the node. Values of node state are:
: unsigned data request struct with retrievals' script
and filters' args
fields encoded as CBOR values serialized as Vec<u8>
arrays.
Data request result stringified as a value.