Update README.md
1 file changed
tree: b3dabd991b0de6813ee237a3762473ad3cde194d
  1. .github/
  2. docs/
  3. resdb_driver/
  4. service/
  5. third_party/
  6. .bazelrc
  7. .gitignore
  8. CNAME
  9. CONTRIBUTING.md
  10. Dockerfile
  11. entrypoint.sh
  12. format.sh
  13. INSTALL.sh
  14. license
  15. NOTICE
  16. README.md
  17. requirements.txt
  18. test_driver.py
  19. test_driver_2.py
  20. test_update_metadata.py
  21. WORKSPACE
README.md

Apache ResilientDB Python SDK (Incubating)

Apache License Python Versions Documentation PRs Welcome Build Status

High-performance blockchain database SDK for Python applications

Quick Start β€’ Documentation β€’ Examples β€’ Contributing β€’ Support

[!NOTE]
Apache ResilientDB is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects.

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/apache/incubator-resilientdb-python-sdk.git
cd incubator-resilientdb-python-sdk

# Set up the environment
sh INSTALL.sh
python3.10 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Basic Usage

from resdb_driver import Resdb
from resdb_driver.crypto import generate_keypair
from typing import Dict, Any

# Initialize the client
db = Resdb('http://127.0.0.1:18000')

# Generate keypairs for the example
alice, bob = generate_keypair(), generate_keypair()

# Create a digital asset
asset = {
    "data": {
        "token_for": "example",
        "description": "Example token",
    },
}

# Prepare transaction
prepared_tx = db.transactions.prepare(
    operation='CREATE',
    signers=alice.public_key,
    recipients=[([bob.public_key], 10)],  # Transfer 10 tokens to Bob
    asset=asset,
)

# Sign the transaction
fulfilled_tx = db.transactions.fulfill(
    prepared_tx, 
    private_keys=alice.private_key
)

# Send the transaction
tx_id_str = db.transactions.send_commit(fulfilled_tx)


# Retrieve the transaction
result = db.transactions.retrieve(fulfilled_tx["id"])
print(f"Retrieved transaction: {result}")

🌟 Features

  • Transaction Management

    • Create and send transactions with digital signatures
    • Retrieve and query transaction details
    • Asset-based transaction querying
  • Block Operations

    • Retrieve blocks by transaction
    • Query block ranges
    • Real-time block updates
  • Asset & Metadata Management

    • Asset search and retrieval
    • Metadata management
    • Output tracking
  • DB Connection

    • Automatic failover
    • Round-robin load balancing
    • Connection pooling
    • Exponential backoff

πŸ“‹ Requirements

  • Python 3.9 or higher
  • Bazel build system
  • Debian based linux distros e.g. Ubuntu
  • Virtual environment (recommended)

πŸ”§ Setup & Configuration

1. Start the Key-Value Service

source venv/bin/activate
sh service/tools/start_kv_service_sdk.sh

2. Start the HTTP Service

bazel build service/http_server/crow_service_main
bazel-bin/service/http_server/crow_service_main \\
    service/tools/config/interface/client.config \\
    service/http_server/server_config.config

πŸ“š Documentation

πŸ—οΈ Project Structure

resilientdb-python-sdk/
β”œβ”€β”€ docs/               # Documentation and guides
β”œβ”€β”€ resdb_driver/      # Core SDK implementation
β”œβ”€β”€ service/           # Service implementations
β”‚   β”œβ”€β”€ http_server/   # HTTP API service (Crow)
β”‚   └── kv_service/    # Key-Value service
└── test/              # Test suite

πŸ§ͺ Testing

TODO: add tests

πŸ” Troubleshooting

Common Issues

  1. Connection Refused

    Solution: Ensure the HTTP service is running on port 18000
    
  2. Python Version Mismatch

    Solution: Use Python 3.9 or higher, preferably in a virtual environment
    
  3. Bazel Build Failures

    Solution: Check Bazel version and ensure all dependencies are installed
    

🀝 Contributing

We welcome contributions! See our Contributing Guidelines for:

  • How to submit patches
  • Development workflow
  • Coding standards

πŸ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

πŸ’¬ Support

πŸ—ΊοΈ Roadmap

Current Goals

  • [ ] Setting up linting (using black)
  • [ ] Convert to pip-installable package
  • [ ] Docker setup for local ResilientDB

Connection Improvements

  • [ ] Connection encryption and authentication options
  • [ ] Load balancing strategies
  • [ ] Metrics and monitoring

API Enhancements

  • [ ] Add async/await support using aiohttp
  • [ ] Improve transaction ID handling