This document provides example curl commands to test the DIG Network RPC server.
- Start the server:
npm start(runs onlocalhost:3141) - Have
curlinstalled (or use PowerShell on Windows)
First, calculate the SHA-256 hash of the URN:
# Using openssl
echo -n "urn:dig:chia:17f89f9af15a046431342694fd2c6df41be8736287e97f6af8327945e59054fb/styles.css" | openssl dgst -sha256 -hex
# Or using Node.js
node -e "const crypto = require('crypto'); console.log(crypto.createHash('sha256').update('urn:dig:chia:17f89f9af15a046431342694fd2c6df41be8736287e97f6af8327945e59054fb/styles.css').digest('hex'))"Then make the RPC call:
curl -X POST http://localhost:3141/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "getContent",
"params": {
"content": "YOUR_HASH_HERE"
},
"id": 1
}'The SHA-256 hash of urn:dig:chia:17f89f9af15a046431342694fd2c6df41be8736287e97f6af8327945e59054fb/styles.css is:
a1b2c3d4e5f6... (calculate this)
curl -X POST http://localhost:3141/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "getContent",
"params": {
"content": "a1b2c3d4e5f6..."
},
"id": 1
}'Run the provided test-rpc.sh script:
chmod +x test-rpc.sh
./test-rpc.shRun the provided test-rpc.ps1 script:
powershell -ExecutionPolicy Bypass -File test-rpc.ps1# Calculate hash first
URN="urn:dig:chia:17f89f9af15a046431342694fd2c6df41be8736287e97f6af8327945e59054fb/styles.css"
HASH=$(echo -n "$URN" | openssl dgst -sha256 -hex | cut -d' ' -f2)
# Make request
curl -X POST http://localhost:3141/rpc \
-H "Content-Type: application/json" \
-d "{
\"jsonrpc\": \"2.0\",
\"method\": \"getContent\",
\"params\": {
\"content\": \"$HASH\"
},
\"id\": 1
}"URN="urn:dig:chia:17f89f9af15a046431342694fd2c6df41be8736287e97f6af8327945e59054fb/index.html"
HASH=$(echo -n "$URN" | openssl dgst -sha256 -hex | cut -d' ' -f2)
curl -X POST http://localhost:3141/rpc \
-H "Content-Type: application/json" \
-d "{
\"jsonrpc\": \"2.0\",
\"method\": \"getContent\",
\"params\": {
\"content\": \"$HASH\"
},
\"id\": 2
}"# Use a fake hash that doesn't exist
FAKE_HASH="0000000000000000000000000000000000000000000000000000000000000000"
curl -X POST http://localhost:3141/rpc \
-H "Content-Type: application/json" \
-d "{
\"jsonrpc\": \"2.0\",
\"method\": \"getContent\",
\"params\": {
\"content\": \"$FAKE_HASH\"
},
\"id\": 3
}"{
"jsonrpc": "2.0",
"result": {
"blob": "base64-encoded-content-here",
"proof": "base64-encoded-proof-here"
},
"id": 1
}{
"jsonrpc": "2.0",
"error": {
"code": -32602,
"message": "Invalid params",
"data": "content parameter is required"
},
"id": 1
}If you have jq installed, pipe the response through it for better formatting:
curl -X POST http://localhost:3141/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "getContent",
"params": {
"content": "YOUR_HASH_HERE"
},
"id": 1
}' | jq '.'- The RPC server returns base64-encoded content in the
blobfield - For non-existent content, a decoy blob is returned (privacy-preserving)
- The
prooffield contains a Merkle proof (mock implementation for testing) - All content is returned as plaintext base64 (encryption skipped for testing)