This guide shows you how to connect CompZ SDK to the real Zcash blockchain for production-grade compliance attestation.
CompZ can operate in two modes:
| Mode | Description | Blockchain | Setup Time |
|---|---|---|---|
| Demo Mode | Uses hosted gateway (placeholder) | Testnet via gateway | 30 seconds |
| Self-Hosted | Your own Zcash node | Real testnet/mainnet | 2-4 hours |
For real blockchain integration, use Self-Hosted mode.
- Docker & Docker Compose installed
- 100GB+ free disk space (for blockchain sync)
- Stable internet connection
- CompZ SDK installed:
pip install -e .
# Start Zcash testnet node
cd /Users/satyamsinghal/Desktop/Products/CompZ
docker-compose up -d zcashd
# Check logs
docker logs -f compz-zcashdWait for sync (2-4 hours for testnet):
# Check sync status
docker exec compz-zcashd zcash-cli -testnet getblockchaininfoLook for "blocks" and "headers" - when they match, you're synced!
# Generate a new shielded address
docker exec compz-zcashd zcash-cli -testnet z_getnewaddress sapling
# Example output: ztestsapling1abc123...xyz789Save this address! You'll need it in your .env file.
Get testnet ZEC from a faucet:
- https://faucet.testnet.z.cash/
- Paste your z-address
- Wait 2-3 minutes for confirmation
Check balance:
docker exec compz-zcashd zcash-cli -testnet z_getbalance "ztestsapling1..."Create .env file:
cp .env.example .envEdit .env:
# Self-Hosted Mode Configuration
ZCASH_RPC_URL=http://localhost:18232
ZCASH_RPC_USER=compz
ZCASH_RPC_PASS=compz_secure_password_change_this
ZCASH_DEFAULT_ADDRESS=ztestsapling1abc123...xyz789 # Your address from Step 2
ZCASH_TESTNET=truefrom compz import CompZClient
# Initialize with self-hosted mode
client = CompZClient(
rpc_url="http://localhost:18232",
rpc_user="compz",
rpc_pass="compz_secure_password_change_this",
default_address="ztestsapling1abc123...xyz789",
testnet=True
)
# Anchor to REAL Zcash blockchain
compliance_data = {
"repo_id": "myorg/myrepo",
"risk_score": 25.5,
"timestamp": "2024-11-26T14:00:00Z"
}
result = client.anchor(compliance_data)
print(f"Anchored to blockchain: {result.txid}")
print(f"View on explorer: {result.explorer_url}")When you call client.anchor():
- Normalize your compliance data to canonical JSON
- Hash with SHA-256 β
0xabc123... - Create memo β
compz:v1:0xabc123... - Send shielded transaction to your own address with memo
- Return TXID β Transaction is now immutable on Zcash blockchain
Testnet: https://explorer.testnet.z.cash/tx/YOUR_TXID
The memo field contains your compliance hash!
# Verify compliance data against blockchain
result = client.verify(compliance_data, txid)
if result.valid:
print("β
Data matches blockchain!")
print(f"On-chain hash: {result.onchain_hash}")
print(f"Confirmations: {result.confirmations}")
else:
print("β Data has been tampered with!")
print(f"Reason: {result.reason}")What happens:
- SDK recomputes hash from your data
- Fetches transaction from blockchain using TXID
- Extracts memo from shielded transaction
- Compares hashes
Result: Cryptographic proof that data hasn't changed since anchoring!
1. Update zcash.conf:
# Change testnet=1 to:
testnet=0
2. Restart node:
docker-compose down
docker-compose up -d zcashd3. Wait for mainnet sync (24-48 hours)
4. Generate mainnet address:
docker exec compz-zcashd zcash-cli z_getnewaddress sapling5. Buy real ZEC and send to your address:
- Purchase from exchange (Coinbase, Kraken, etc.)
- Send to your shielded address
- Each transaction costs
0.0001 ZEC ($0.003)
6. Update .env:
ZCASH_TESTNET=false
ZCASH_DEFAULT_ADDRESS=zs1abc123...xyz789 # Mainnet address| Network | Cost per Anchor | Total for 1000 Anchors |
|---|---|---|
| Testnet | FREE (faucet) | FREE |
| Mainnet |
Compare to alternatives:
- Ethereum: $5-50 per transaction
- Bitcoin: $1-10 per transaction
- Zcash: $0.003 per transaction β
# Check peers
docker exec compz-zcashd zcash-cli -testnet getpeerinfo
# Restart node
docker-compose restart zcashd# Check balance
docker exec compz-zcashd zcash-cli -testnet z_getbalance "YOUR_ADDRESS"
# Get more from faucetThe memo is in the shielded transaction. You need:
- Viewing key or spending key
- Use
z_viewtransactionRPC command
CompZ SDK handles this automatically!
# Blockchain info
docker exec compz-zcashd zcash-cli -testnet getblockchaininfo
# Wallet info
docker exec compz-zcashd zcash-cli -testnet getwalletinfo
# Network info
docker exec compz-zcashd zcash-cli -testnet getnetworkinfodocker exec compz-zcashd zcash-cli -testnet z_listreceivedbyaddress "YOUR_ADDRESS"name: Compliance Anchor
on:
push:
branches: [main]
jobs:
anchor:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run security scan
run: ./scan.sh
- name: Anchor to blockchain
env:
ZCASH_RPC_URL: ${{ secrets.ZCASH_RPC_URL }}
ZCASH_RPC_USER: ${{ secrets.ZCASH_RPC_USER }}
ZCASH_RPC_PASS: ${{ secrets.ZCASH_RPC_PASS }}
ZCASH_DEFAULT_ADDRESS: ${{ secrets.ZCASH_ADDRESS }}
run: |
pip install compz
compz anchor compliance_result.json -o anchor_result.json
- name: Save TXID
run: |
TXID=$(jq -r '.txid' anchor_result.json)
echo "TXID: $TXID" >> $GITHUB_STEP_SUMMARYCompZ uses Zcash shielded transactions (not transparent):
- β Privacy: Transaction amounts hidden
- β Memo field: 512 bytes for your hash
- β Encryption: Only you can read the memo
- β Immutable: Can't be changed once confirmed
Your App
β
CompZ SDK (normalize β hash)
β
Zcash RPC (z_sendmany)
β
Local Zcash Node
β
Zcash Network (shielded pool)
β
Blockchain (immutable record)
β
Block Explorer (public verification)
β NOT on blockchain: Your actual compliance data
β
ON blockchain: SHA-256 hash (cryptographic fingerprint)
Result: Public verifiability + Private data!
Anyone with TXID can verify:
curl https://explorer.testnet.z.cash/api/tx/YOUR_TXIDOnly you can read memo (requires viewing key):
docker exec compz-zcashd zcash-cli -testnet z_viewtransaction YOUR_TXIDCompZ SDK handles both automatically!
For high-volume anchoring:
- Run multiple nodes (load balancing)
- Use LightwalletD (faster sync)
- Batch transactions (coming soon)
- Consider enterprise gateway (contact us)
- Issues: https://github.com/Compliledger/CompZ/issues
- Docs: https://github.com/Compliledger/CompZ
- Zcash Docs: https://zcash.readthedocs.io/
You now have:
- β Real Zcash node running
- β Funded testnet address
- β CompZ SDK configured
- β Ready to anchor to blockchain
Next: Run the example in examples/self_hosted_example.py