Skip to content

Latest commit

 

History

History
119 lines (91 loc) · 3.33 KB

File metadata and controls

119 lines (91 loc) · 3.33 KB

Nimiq JSON-RPC Specification

Through the use of JSON-RPC, Nimiq nodes expose a set of standardized methods and endpoints that allow external applications and tools to interact, stream and control the behavior of the nodes. This includes functionalities such as retrieving information about the blockchain state, submitting transactions, managing accounts, and configuring node settings.

Authentication

Authentication with the JSON-RPC server occurs via HTTP Basic Authentication. The username and password can be configured within the rpc-server section of the client.toml file. Authentication with the RPC server functions by adding an Authorization header to the HTTP request. The value of this header is provided in the format Basic <credentials> where credentials is a base64-encoded string containing the username and password separated by a colon.

echo -n 'super:secret' | base64
# Output: c3VwZXI6c2VjcmV0

curl --request POST \
    --url http://127.0.0.1:8648 \
    --header 'Authorization: Basic c3VwZXI6c2VjcmV0' \
    --header 'Content-Type: application/json' \
    --data '{
    "jsonrpc": "2.0",
    "method": "getLatestBlock",
    "params": [false],
    "id": 1
}'

Passing parameters to RPC methods

The JSON-RPC specification defines two ways of passing parameters to methods: named parameters, providing flexibility by labeling parameters, and positional parameters, relying on their order in the request. At the moment the JSON-RPC server implementation only supports positional parameters, meaning parameter order must match the server's expectation.

{
    "jsonrpc": "2.0",
    "params": {"hour": 12, "minutes": 30}, // [!code --]
    "params": [12, 30], // [!code ++]
}

Methods

<style> .prose > * { margin: 0; } section { --uno: flex gap-32 items-start max-w-inherit flex-col; @media (min-width: 768px) { flex-direction: row; } .io { --uno: shrink basis-30ch m-0; h4 { --uno: text-12 text-neutral-800 mt-32 mb-16; } ul { --uno: pl-4; li::before { --uno: mr-4; } span { --uno: text-12; } } } .vp-code-group { --uno: flex-1 w-full; .line span { --uno: text-12 }; @media (min-width: 768px) { overflow-x: auto; } } } </style>