Catalog PyPI
Back to packageRELEASE DETAILS

0.2.9

PyPI

aiblock

Python SDK for interacting with the AIBlock blockchain

aiblockblockchaincryptocurrency
Published7 Oct 2025
Direct dependencies7
Transitive dependenciesNot calculated

README

Version 0.2.9 documentation

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

Basic Blockchain Queries

from aiblock.blockchain import BlockchainClient

# Initialize blockchain client
client = BlockchainClient(
    storage_host='https://storage.aiblock.dev',
    mempool_host='https://mempool.aiblock.dev'
)

# Query blockchain
latest_block = client.get_latest_block()
if latest_block.is_ok:
    print(f"Latest block: {latest_block.get_ok()['content']['block_num']}")

# Get specific block by number
block = client.get_block_by_num(1)
if block.is_ok:
    print(f"Block 1: {block.get_ok()['content']}")

# Get blockchain entry by hash
entry = client.get_blockchain_entry('some_hash')

# Get transaction by hash
transaction = client.get_transaction_by_hash('tx_hash')

# Get multiple transactions
transactions = client.fetch_transactions(['hash1', 'hash2'])

# Get supply information (requires mempool host)
total_supply = client.get_total_supply()
issued_supply = client.get_issued_supply()

Wallet Operations

from aiblock.wallet import Wallet

# Create wallet
wallet = Wallet()

# Generate seed phrase
seed_phrase = wallet.generate_seed_phrase()
print(f"Seed phrase: {seed_phrase}")

# Initialize wallet from seed
config = {
    'passphrase': 'your-secure-passphrase',
    'mempoolHost': 'https://mempool.aiblock.dev',
    'storageHost': 'https://storage.aiblock.dev',
    'valenceHost': 'https://valence.aiblock.dev'
}

result = wallet.from_seed(seed_phrase, config)
if result.is_ok:
    print(f"Wallet address: {wallet.get_address()}")
else:
    print(result.error, result.error_message)

Features

Blockchain Client

  • get_latest_block() - Get the latest block information
  • get_block_by_num(block_num) - Get a specific block by number
  • get_blockchain_entry(hash) - Get blockchain entry by hash
  • get_transaction_by_hash(tx_hash) - Get transaction details
  • fetch_transactions(tx_hashes) - Get multiple transactions
  • get_total_supply() - Get total token supply
  • get_issued_supply() - Get issued token supply

Wallet Operations

  • Generate and manage seed phrases
  • Create and manage keypairs
  • Create and sign transactions
  • Create item assets
  • Check balances
  • 2WayPayment protocol support

Configuration

The SDK uses environment variables for configuration. Create a .env file:

AIBLOCK_PASSPHRASE="your-secure-passphrase"
AIBLOCK_STORAGE_HOST="https://storage.aiblock.dev"
AIBLOCK_MEMPOOL_HOST="https://mempool.aiblock.dev"
AIBLOCK_VALENCE_HOST="https://valence.aiblock.dev"

Error Handling

All methods return IResult objects with proper error handling:

result = client.get_latest_block()
if result.is_ok:
    data = result.get_ok()
    print(f"Success: {data}")
else:
    print(result.error, result.error_message)

Development

  1. Clone the repository
  2. Install uv (https://docs.astral.sh/uv/)
  3. Run tests: uv pip install -q pytest requests-mock && uv run pytest -q

All 68 tests pass, ensuring reliability and compatibility.

Documentation

Contributing

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

License

MIT License

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 7

Native requirements
7 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
requests
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.8",
  "evaluation": "NOT_EVALUATED"
}
requests>=2.25.1runtime
pynacl
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.8",
  "evaluation": "NOT_EVALUATED"
}
pynacl>=1.4.0runtime
mnemonic
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.8",
  "evaluation": "NOT_EVALUATED"
}
mnemonic>=0.20runtime
typing-extensions
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.8",
  "evaluation": "NOT_EVALUATED"
}
typing-extensions>=4.0.0runtime
base58
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.8",
  "evaluation": "NOT_EVALUATED"
}
base58>=2.1.1runtime
python-dotenv
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.8",
  "evaluation": "NOT_EVALUATED"
}
python-dotenv>=1.0.0runtime
bip32utils
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.8",
  "evaluation": "NOT_EVALUATED"
}
bip32utils>=0.3.0runtime

Distribution files

2 collected
aiblock-0.2.9-py3-none-any.whl

bdist_wheel · 32.28 KB · Python py3

Source file
aiblock-0.2.9.tar.gz

sdist · 68.78 KB · Python source

Source file

Repository

PENDING
aiblockofficial/2way.py

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 10:01 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:dfa9d551cef314d62637fda8871e3e91f1bdbaffe82f2c02701ef958e6147dae

Other collected versions

View all collected versions →