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
- Clone the repository
- Install dependencies:
pip install -r requirements.txt - Install test dependencies:
pip install -r requirements-test.txt - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiblock-0.2.3.tar.gz.
File metadata
- Download URL: aiblock-0.2.3.tar.gz
- Upload date:
- Size: 30.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c94918b3450b6c3f06987f69f2a6a65408452d345cee2730705b0ef83b36a78f
|
|
| MD5 |
a651e95f42d6d86bb681c0e17dfd931f
|
|
| BLAKE2b-256 |
c3340b3199e0b6009757c8c1baf8a9ad63c4febe2af022f4907b375fe917fddd
|
File details
Details for the file aiblock-0.2.3-py3-none-any.whl.
File metadata
- Download URL: aiblock-0.2.3-py3-none-any.whl
- Upload date:
- Size: 30.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b27ecf2304fc5dc5287b0feb9ac6760349583deb8850228c0e212ffb9f38b759
|
|
| MD5 |
5e14453b7266643c7fc08e3497a727ff
|
|
| BLAKE2b-256 |
c67f27e60d27c4e5526cdcd9e18e1f648cbb000876d7a53eba3d18de2532f03a
|