Back to Documentation

Examples & Demos

Practical code examples to get you started with the Decentralized Rights Protocol.

Quick Start

Clone the repository and run the testnet node to get started immediately.

# Clone repository
git clone https://github.com/Decentralized-Rights-Protocol/Dr-Blockchain.git
# Install dependencies
pip install -r requirements.txt
# Run testnet node
python src/node.py

Basic Node Setup

Initialize and run a DRP node

python
# Install dependencies
pip install -r requirements.txt

# Initialize node
from drp.node import DRPNode

node = DRPNode(
    host='0.0.0.0',
    port=8080,
    testnet=True
)

# Start node
node.start()

Proof of Status Verification

Verify user status in the network

python
from drp.consensus import verify_status

# Verify user status
user_id = "user_12345"
status = verify_status(user_id)

if status.is_verified:
    print(f"User {user_id} has status: {status.level}")
    print(f"Voting power: {status.voting_power}")
else:
    print("User status not verified")

Submit Activity Proof

Submit proof of activity for rewards

python
from drp.consensus import submit_activity

# Create activity proof
activity = {
    "type": "node_operation",
    "duration": 3600,  # 1 hour
    "energy_source": "renewable",
    "contributions": [
        "processed_transactions",
        "maintained_network"
    ]
}

# Submit proof
result = submit_activity(user_id="user_12345", activity=activity)

if result.success:
    print(f"Activity verified! Reward: {result.reward} $DeRi")
else:
    print(f"Activity rejected: {result.reason}")

Post-Quantum Key Generation

Generate quantum-safe cryptographic keys

python
from drp.crypto import generate_kyber_keys

# Generate CRYSTALS-Kyber key pair
public_key, private_key = generate_kyber_keys()

print(f"Public Key: {public_key.hex()}")
print(f"Private Key: {private_key.hex()}")

# Key pair is quantum-resistant and ready for use

Transaction Signing

Sign a transaction with post-quantum signature

python
from drp.crypto import sign_transaction, verify_signature

# Create transaction
transaction = {
    "from": "user_12345",
    "to": "user_67890",
    "amount": 100.0,
    "token": "DeRi"
}

# Sign transaction
signature = sign_transaction(transaction, private_key)

# Verify signature
is_valid = verify_signature(transaction, signature, public_key)

if is_valid:
    print("Transaction signature is valid")
    # Submit transaction to network
else:
    print("Invalid signature")

AI Verification Check

Check AI verification status for activity

python
from drp.ai import AIElder

# Initialize AI Elder
ai_elder = AIElder()

# Verify activity
activity_data = {
    "user_id": "user_12345",
    "activity_type": "governance_vote",
    "timestamp": "2024-01-15T10:30:00Z",
    "details": {...}
}

verification = ai_elder.verify(activity_data)

if verification.is_legitimate:
    print(f"Activity verified by AI. Score: {verification.reputation_score}")
else:
    print(f"Activity flagged: {verification.reason}")

Full Documentation

Explore comprehensive guides and API references.

View Docs

GitHub Repository

Browse the source code and contribute to the project.

Visit GitHub