Getting Started with ACDC SDKs¶
The ACDC SDK provides programmatic access to both Alpha and Delta chains. Choose the SDK that matches your development environment.
Available SDKs¶
| Language | Package | Status |
|---|---|---|
| TypeScript/JavaScript | @acdc/sdk |
Stable |
| Rust | acdc-sdk |
Stable |
| Python | acdc-py |
Coming Soon |
Quick Start¶
TypeScript/JavaScript¶
import { AcdcClient } from '@acdc/sdk';
// Connect to Delta chain mainnet
const client = new AcdcClient({
chain: 'delta',
network: 'mainnet'
});
// Get account balance
const balance = await client.getBalance('dx1abc123...');
console.log(`Balance: ${balance.formatted} ACDC`);
Rust¶
use acdc_sdk::{AcdcClient, Network};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = AcdcClient::new(Network::DeltaMainnet)?;
let balance = client.get_balance("dx1abc123...").await?;
println!("Balance: {} ACDC", balance.formatted());
Ok(())
}
Configuration¶
Client Options¶
import { AcdcClient } from '@acdc/sdk';
const client = new AcdcClient({
// Required
chain: 'delta', // 'alpha' or 'delta'
network: 'mainnet', // 'mainnet' or 'testnet'
// Optional
rpcUrl: 'https://...', // Custom RPC endpoint
wsUrl: 'wss://...', // Custom WebSocket endpoint
apiKey: 'your-api-key', // API key for higher rate limits
timeout: 30000, // Request timeout (ms)
retries: 3, // Number of retries
});
Environment Variables¶
The SDK can be configured via environment variables:
# .env
ACDC_CHAIN=delta
ACDC_NETWORK=mainnet
ACDC_RPC_URL=https://delta-rpc.ac-dc.network
ACDC_API_KEY=your-api-key
import { AcdcClient } from '@acdc/sdk';
// Automatically reads from environment
const client = AcdcClient.fromEnv();
Core Concepts¶
Dual-Chain Architecture¶
ACDC consists of two interconnected chains:
- Alpha Chain: UTXO/record-based model for privacy-preserving transactions
- Delta Chain: Account-based model for DeFi, governance, and staking
The SDK provides a unified interface for both chains while exposing chain-specific functionality when needed.
Address Formats¶
| Chain | Prefix | Example |
|---|---|---|
| Alpha | ax1 |
ax1qz3k7m8n9p0r2s4t6v8w0x2y4z6a8c0e2g4i6k8m |
| Delta | dx1 |
dx1abc123def456ghi789jkl012mno345pqr678stu |
Units and Decimals¶
ACDC uses 18 decimal places:
import { parseUnits, formatUnits } from '@acdc/sdk';
// Convert human-readable to base units
const amount = parseUnits('1.5', 18); // 1500000000000000000n
// Convert base units to human-readable
const formatted = formatUnits(1500000000000000000n, 18); // "1.5"
Common Operations¶
Check Balance¶
const balance = await client.getBalance('dx1abc123...');
console.log(balance.raw); // BigInt: 1000000000000000000n
console.log(balance.formatted); // String: "1.0"
console.log(balance.symbol); // String: "ACDC"
Send Transaction¶
import { Wallet } from '@acdc/sdk';
// Create wallet from private key
const wallet = Wallet.fromPrivateKey('0x...');
// Connect wallet to client
const connectedWallet = wallet.connect(client);
// Send transaction
const tx = await connectedWallet.sendTransaction({
to: 'dx1recipient...',
value: parseUnits('1.0', 18)
});
console.log(`Transaction hash: ${tx.hash}`);
// Wait for confirmation
const receipt = await tx.wait();
console.log(`Confirmed in block ${receipt.blockNumber}`);
Subscribe to Events¶
// Subscribe to new blocks
client.on('block', (block) => {
console.log(`New block: ${block.number}`);
});
// Subscribe to address activity
client.on('address', 'dx1abc123...', (tx) => {
console.log(`Transaction: ${tx.hash}`);
});
Error Handling¶
import { AcdcError, RpcError, NetworkError } from '@acdc/sdk';
try {
const balance = await client.getBalance('invalid-address');
} catch (error) {
if (error instanceof RpcError) {
console.error(`RPC Error: ${error.code} - ${error.message}`);
} else if (error instanceof NetworkError) {
console.error(`Network Error: ${error.message}`);
} else {
throw error;
}
}
Next Steps¶
- TypeScript SDK Guide - Detailed TypeScript SDK documentation
- Rust SDK Guide - Detailed Rust SDK documentation
- Tutorials - Step-by-step tutorials