API Reference

Comprehensive API documentation for interacting with the Blocana blockchain

Transaction Pool API

The Transaction Pool is responsible for managing unconfirmed transactions that are waiting to be included in blocks. It handles transaction validation, prioritization, and selection for block creation.

Creating a Transaction Pool

// Create with default configuration
let pool = TransactionPool::new();

// Create with custom configuration
let config = TransactionPoolConfig {
    max_size: 5000,
    expiry_time: 3600, // 1 hour in seconds
    max_memory: 32 * 1024 * 1024, // 32 MB
    min_fee_per_byte: 1, // Minimum fee per byte for acceptance
};
let pool = TransactionPool::with_config(config);
ParameterTypeDescription
max_sizeu32Maximum number of transactions allowed in the pool
expiry_timeu64Time in seconds after which transactions are removed from the pool
max_memoryusizeMaximum memory allocation for the transaction pool in bytes
min_fee_per_byteu64Minimum fee required per byte of transaction data

Adding Transactions

// Add a single transaction to the pool
let result = pool.add_transaction(transaction, &blockchain_state)?;

// Add multiple transactions to the pool
let results = pool.add_transactions(transactions, &blockchain_state)?;

Returns a Result indicating success or an error with details of why the transaction was rejected.

Possible Errors

  • PoolFull - Transaction pool has reached maximum capacity
  • InsufficientFee - Transaction fee is below the required minimum
  • DuplicateTransaction - Transaction is already in the pool
  • ValidationError - Transaction fails validation checks
  • ExceededMemoryLimit - Adding transaction would exceed memory limit

Retrieving and Managing Transactions

// Get all pending transactions
let all_transactions = pool.get_pending_transactions();

// Get transactions ordered by fee (highest first)
let ordered_transactions = pool.get_transactions_by_fee(max_count);

// Remove a specific transaction
pool.remove_transaction(&transaction_hash);

// Clear expired transactions
let removed_count = pool.clear_expired(current_timestamp);

// Check if a transaction exists in the pool
let exists = pool.contains_transaction(&transaction_hash);

Blockchain API

Documentation for this API section is coming soon.

Coming soon in next update

Consensus API

Documentation for this API section is coming soon.

Coming soon in next update

API Client Libraries

The following client libraries are available for interacting with the Blocana API in different programming languages:

JavaScript/TypeScript

npm package for Node.js and browser applications

npm install @blocana/client

Rust

Rust crate for native integration

blocana-client = "0.1.0"

Python

Python package for data analysis and applications

pip install blocana-client