This document provides cURL commands to interact with the ChainLite API. The production server is available at https://chainlite.onrender.com.
{
"sender": "string (required, regex: ^0x[a-fA-F0-9]{6,}$)",
"recipient": "string (required, regex: ^0x[a-fA-F0-9]{6,}$)",
"amount": "number (required, must be > 0)",
"signature": "string (required, min length: 1)",
"timestamp": "integer (required, epoch milliseconds)"
}{
"nodes": ["string array (required, min items: 1)"]
}- All wallet addresses must follow the format:
^0x[a-fA-F0-9]{6,}$ - Example valid address:
0xabc123456789
Most endpoints return data in this structure:
{
"data": { /* endpoint-specific data */ },
"message": "string (for some endpoints)"
}curl -X 'GET' \
'https://chainlite.onrender.com/' \
-H 'accept: application/json'Request Validation:
senderandrecipientmust be valid hex addresses (format:^0x[a-fA-F0-9]{6,}$)amountmust be positive numbersignatureandtimestampare required fields- Server auto-generates transaction hash based on all fields
curl -X 'POST' \
'https://chainlite.onrender.com/transactions' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"sender": "0xabc123456789",
"recipient": "0xdef987654321",
"amount": 10.5,
"signature": "signed_payload_hex_or_base64",
"timestamp": 1712345678901
}'Response: Returns the created transaction object with auto-generated hash.
Optional Parameters:
miner_address(query param): Valid hex address to receive mining reward (defaults to node identifier)
Process:
- Performs proof-of-work algorithm
- Adds reward transaction (1 coin to miner)
- Creates new block with all pending transactions
- Validates miner address format if provided
curl -X 'GET' \
'https://chainlite.onrender.com/mine' \
-H 'accept: application/json'With custom miner address:
curl -X 'GET' \
'https://chainlite.onrender.com/mine?miner_address=0xabc123456789' \
-H 'accept: application/json'Response Format:
{
"message": "New block forged",
"index": 2,
"transactions": [...],
"nonce": 12345,
"hash": "000abc123...",
"previous_hash": "000def456..."
}Returns full chain from database with each block including:
index,timestamp,transactions(without internal_id),nonce(mapped from internalproof),previous_hash, and computedhash.
curl -X 'GET' \
'https://chainlite.onrender.com/chain' \
-H 'accept: application/json'Response Shape:
{
"data": {
"chain": [
{
"index": 1,
"timestamp": 1712345678901,
"transactions": [...],
"nonce": 100,
"previous_hash": null,
"hash": "0000..."
}
]
}
}- If body
nodesis empty or omitted, the server auto-registers itself using its IP and the request port for mobile-friendly access. - Each node can be provided with or without scheme; it will be normalized internally.
- Successful registrations are broadcast to existing peers.
curl -X 'POST' \
'https://chainlite.onrender.com/nodes' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"nodes": [
"http://node1:8000",
"http://node2:8000"
]
}'Applies consensus algorithm by checking all registered nodes for the longest valid chain.
curl -X 'GET' \
'https://chainlite.onrender.com/nodes/resolve' \
-H 'accept: application/json'Response (Chain Replaced):
{
"message": "Chain was replaced",
"chain": [
{
"index": 1,
"timestamp": 1712345678901,
"transactions": [...],
"nonce": 100,
"previous_hash": null,
"hash": "000..."
}
]
}Response (Local Chain Authoritative):
{
"message": "Local chain is authoritative"
}Here's a sequence of commands to test the basic flow:
-
Create a transaction:
curl -X 'POST' \ 'https://chainlite.onrender.com/transactions' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "sender": "0xabc123456789", "recipient": "0xdef987654321", "amount": 10.5, "signature": "signed_payload_hex_or_base64", "timestamp": 1712345678901 }'
-
Mine a block:
curl -X 'GET' 'https://chainlite.onrender.com/mine'
-
View the blockchain:
curl -X 'GET' 'https://chainlite.onrender.com/chain'
-
Register a peer node (if you have another instance running):
curl -X 'POST' 'https://chainlite.onrender.com/nodes' -H 'Content-Type: application/json' -d '{"nodes":["http://node1:8000"]}'
-
Resolve conflicts (if you have multiple nodes):
curl -X 'GET' 'https://chainlite.onrender.com/nodes/resolve'
To test the full functionality with multiple nodes, you'll need to:
- Ensure additional nodes are reachable (e.g.,
http://node1:8000,http://node2:8000).