JSON-RPC API
The Conduct Protocol JSON-RPC API provides comprehensive access to blockchain data and operations, following the JSON-RPC 2.0 specification.
Overview
The JSON-RPC API allows you to:
- Query blockchain data and state
- Submit transactions to the network
- Retrieve account information
- Access block and transaction details
Configuration
Base URL
http://localhost:5467/
Required Headers
All requests must include:
Content-Type: application/json
JSON-RPC 2.0 Format
All requests follow the JSON-RPC 2.0 specification:
{
"jsonrpc": "2.0",
"method": "cndt_methodName",
"params": [...],
"id": 1
}
Quick Start Example
Get the current blockchain tip:
curl -X POST http://localhost:5467 \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "cndt_getTip",
"params": [],
"id": 1
}'
Data Types and Encoding
Encoding Standards
- Base58 encoding - Used for IDs, addresses, and signatures
- String representation - Large integers are represented as strings to avoid precision loss
- Hexadecimal - Used for raw binary data where applicable
Block References
The API supports multiple formats for referencing blocks:
- String number - Block height or depth as a string
- Base58 block ID - Unique block identifier
- Numeric value - Block height or depth as a number
API Methods
Blockchain Information
cndt_getTip
Get the current blockchain tip (latest block).
{
"jsonrpc": "2.0",
"method": "cndt_getTip",
"params": [],
"id": 1
}
cndt_getHeader
Retrieve a block header by reference.
{
"jsonrpc": "2.0",
"method": "cndt_getHeader",
"params": [block_reference],
"id": 1
}
cndt_getBody
Get block body data by merkle root.
{
"jsonrpc": "2.0",
"method": "cndt_getBody",
"params": [merkle_root],
"id": 1
}
Transaction Operations
cndt_getTransaction
Fetch a specific transaction by its ID.
{
"jsonrpc": "2.0",
"method": "cndt_getTransaction",
"params": [transaction_id],
"id": 1
}
cndt_getTransactionOutput
Get a specific transaction output.
{
"jsonrpc": "2.0",
"method": "cndt_getTransactionOutput",
"params": [transaction_id, output_index],
"id": 1
}
cndt_submitTransaction
Submit a signed transaction to the network.
{
"jsonrpc": "2.0",
"method": "cndt_submitTransaction",
"params": [signed_transaction],
"id": 1
}
Account Information
cndt_getAddressState
List all spendable transaction outputs for a given address.
{
"jsonrpc": "2.0",
"method": "cndt_getAddressState",
"params": [address],
"id": 1
}
Error Handling
The API follows JSON-RPC 2.0 error handling standards. Common error codes include:
| Code | Message | Description |
|---|---|---|
-32700 | Parse error | Invalid JSON was received |
-32600 | Invalid request | The JSON sent is not a valid request object |
-32601 | Method not found | The method does not exist or is not available |
-32602 | Invalid parameters | Invalid method parameter(s) |
-32603 | Internal error | Internal JSON-RPC error |
Example Error Response
{
"jsonrpc": "2.0",
"error": {
"code": -32601,
"message": "Method not found"
},
"id": 1
}
Best Practices
- Always include the
jsonrpcfield with value"2.0" - Use appropriate content type headers
- Handle errors gracefully by checking for the
errorfield in responses - Use string representation for large numeric values to avoid precision loss
- Implement proper timeout handling for network requests