Skip to main content

Python SDK for interacting with the AIBlock blockchain

Project description

AIBlock Python SDK

Python SDK for interacting with the AIBlock blockchain. This SDK provides a simple interface for wallet operations and blockchain queries.

Installation

pip install aiblock

Quick Start

Configuration Setup

The SDK uses environment variables for configuration:

# Required environment variables
export AIBLOCK_PASSPHRASE="your-secure-passphrase"

# Optional environment variables (defaults shown)
export AIBLOCK_STORAGE_HOST="https://storage.aiblock.dev"
export AIBLOCK_MEMPOOL_HOST="https://mempool.aiblock.dev"
export AIBLOCK_VALENCE_HOST="https://valence.aiblock.dev"

Basic Usage

from aiblock.wallet import Wallet
from aiblock.blockchain import BlockchainClient
from aiblock.config import get_config, validate_env_config

# Get and validate configuration
config = get_config()
error = validate_env_config(config)
if error:
    print(f"Configuration error: {error}")
    exit(1)

# Initialize blockchain client
blockchain_client = BlockchainClient(
    storage_host=config['storageHost'],
    mempool_host=config['mempoolHost']
)

# Create and initialize wallet
wallet = Wallet()
seed_phrase = wallet.generate_seed_phrase()
keypair = wallet.generate_keypair()

# Query blockchain
latest_block = blockchain_client.get_latest_block()
total_supply = blockchain_client.get_total_supply()
issued_supply = blockchain_client.get_issued_supply()
balance = blockchain_client.get_balance(keypair['address'])

Features

Wallet Operations

  • Generate and manage seed phrases
  • Create and manage keypairs
  • Create and sign transactions
  • Create item assets
  • Check balances

Blockchain Operations

  • Query latest block
  • Get block by number
  • Get blockchain entry by hash
  • Get total supply
  • Get issued supply
  • Get balance for address

Example Usage

See the documentation for more advanced usage and examples, including:

  • Wallet initialization
  • Keypair generation
  • Blockchain queries
  • Asset creation
  • Transaction creation
  • 2WayPayment protocol

Development

  1. Clone the repository
  2. Install dependencies: pip install -r requirements.txt
  3. Install test dependencies: pip install -r requirements-test.txt
  4. Run tests: pytest

Contributing

We welcome contributions! Please feel free to submit a Pull Request.

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiblock-0.2.6.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiblock-0.2.6-py3-none-any.whl (32.2 kB view details)

Uploaded Python 3

File details

Details for the file aiblock-0.2.6.tar.gz.

File metadata

  • Download URL: aiblock-0.2.6.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for aiblock-0.2.6.tar.gz
Algorithm Hash digest
SHA256 968c0ab090f106ce89cc0753c2542dc21a28afc8c1aa9db3b5500dc748cbbcab
MD5 c267cddc80ec837c9a118569645d8712
BLAKE2b-256 9a42dc8988420c8915fdf2a8a0691bfa4b1f0611f2a6b7cb6ec1ecc7fe4c912b

See more details on using hashes here.

File details

Details for the file aiblock-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: aiblock-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 32.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for aiblock-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 a3b1e18cbcde0780f6bf90de2b41491f5138d8192fea8e200b578ede1c29fc62
MD5 bd788f0053d7251ce35c46d3dd1890eb
BLAKE2b-256 1a51aa0df736c5fa120bb921e5b601d2751bc2415d215591d021bcbcd5a7f8f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page