Getting Started
This guide will help you quickly set up and start using Shield for submitting private Bitcoin transactions.
Prerequisites
Before using Shield, you should have:
- Basic understanding of Bitcoin transactions
- The ability to create and sign raw Bitcoin transactions
- A tool or library capable of making HTTP requests (curl, request, axios, etc.)
Submit a transaction
1. Get Shield Fee Information
First, query Shield to get the current payment address and fee rates:
curl -XGET 'https://shield.rebarlabs.io/v1/info'
You'll receive a response like:
{
"height": 886512,
"payment": {
"p2wpkh": "bc1q..."
},
"fees": [
{
"estimated_hashrate": 0.12,
"feerate": 18.0
},
{
"estimated_hashrate": 0.27,
"feerate": 24.0
}
]
}
2. Create a Transaction with Shield Fee
When creating your Bitcoin transaction, add a Shield fee output:
- Choose a fee tier from the response above based on your confirmation needs. The
estimated_hashraterepresents an estimate of the cumulative % hashrate of the network's hashrate available at a given fee, and the corresponding fee rate (in sats/vbyte) - Add an output paying the Shield fee address
- Calculate the fee:
Transaction Size (vbytes) × Fee Rate (sats/vbyte) - Set the Shield fee output to this amount (inputs must equal outputs — the implicit Bitcoin fee must be zero)
3. Submit the Transaction
Submit your signed transaction to Shield:
curl -XPOST 'https://shield.rebarlabs.io/v1/rpc' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "1.0",
"id": "1",
"method": "sendrawtransaction",
"params": ["YOUR_SIGNED_TRANSACTION_HEX"]
}'
On success, you'll receive the transaction ID:
{
"result": "txid_hex_string",
"error": null,
"id": "1"
}
Code Examples
JavaScript (Node.js with axios)
const axios = require('axios');
async function submitTransaction(txHex) {
try {
// Get fee information
const infoResponse = await axios.get('https://shield.rebarlabs.io/v1/info');
console.log('Payment address:', infoResponse.data.payment.p2wpkh);
console.log('Fee options:', infoResponse.data.fees);
// Submit transaction
const response = await axios.post('https://shield.rebarlabs.io/v1/rpc', {
jsonrpc: '1.0',
id: 'shield',
method: 'sendrawtransaction',
params: [txHex],
});
console.log('Transaction submitted:', response.data.result);
return response.data.result;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
throw error;
}
}
// Usage
// submitTransaction('YOUR_SIGNED_TRANSACTION_HEX');
Next Steps
- Transaction Fees — How Shield fees work
- Selecting Hashrate — Choose the right fee tier for your confirmation needs