SDK Guide
The Rivellum TypeScript SDK (@rivellum/sdk) provides a comprehensive client library for interacting with the Rivellum blockchain.
🔗 Interactive API Documentation: Explore all SDK methods and their corresponding API endpoints in the API Explorer with live testing and ready-to-use code examples.
Installation
npm install @rivellum/sdk
Basic Usage
import { RivellumClient } from '@rivellum/sdk';
const client = new RivellumClient({
nodeUrl: 'https://rpc.rivellum.network',
timeout: 30000
});
// Check node health
const isHealthy = await client.isHealthy();
// Get ledger tip
const tip = await client.getLedgerTip();
console.log(`Current height: ${tip.height}`);
Account Operations
Get Account Balance
const balance = await client.getBalance('0x1234...');
console.log(`Balance: ${balance.balance}`);
console.log(`Nonce: ${balance.nonce}`);
Account Timeline
const timeline = await client.getAccountTimeline('0x1234...', {
limit: 50,
offset: 0
});
timeline.entries.forEach(entry => {
console.log(`Intent ${entry.intent_id} at height ${entry.height}`);
});
NFT Operations
See NFT Standard for full details.
List NFT Collections
const collections = await client.listCollections(1, 20);
console.log(`Total collections: ${collections.total}`);
collections.collections.forEach(col => {
console.log(`${col.name}: ${col.minted}/${col.max_supply} minted`);
});
Get Collection Details
const collection = await client.getCollection('collection_id_here');
console.log(`Collection: ${collection.name}`);
console.log(`Creator: ${collection.creator}`);
console.log(`Royalty: ${collection.royalty_percentage}%`);
Get NFT Metadata
const nft = await client.getNftMetadata('nft_id_here');
console.log(`NFT: ${nft.name}`);
console.log(`Owner: ${nft.owner}`);
console.log(`Media: ${nft.media_uri}`);
List NFTs Owned by Address
const owned = await client.getNftsOwnedBy('0x1234...', 1, 20);
console.log(`${owned.total} NFTs owned`);
owned.nfts.forEach(nft => {
console.log(`- ${nft.name} (${nft.id})`);
});
Get NFT Transfer History
const history = await client.getNftTransferHistory('nft_id_here', 1, 20);
console.log(`${history.total} transfers`);
history.transfers.forEach(transfer => {
console.log(`${transfer.from_address} → ${transfer.to_address}`);
});
Account Authentication
See Account Auth for full details on post-quantum signatures and multi-sig.
Get Account Auth Configuration
const auth = await client.getAccountAuth('0x1234...');
if (auth) {
console.log(`Key Scheme: ${auth.key_scheme}`);
if (auth.key_scheme === 'multi_sig') {
console.log(`Threshold: ${auth.threshold}/${auth.public_keys.length}`);
}
}
Intent Operations
Submit Intent
const intentData = {
sender: '0x1234...',
nonce: 1,
max_gas: 1000000,
payload: {
type: 'transfer',
to: '0x5678...',
amount: '1000'
}
};
// Build encrypted envelope and submit via sealed-batch ingress
const envelope = await buildEncryptedEnvelope(intentData);
const result = await client.submitEnvelope(envelope);
console.log(`Envelope submitted: ${result.envelope_id}`);
Get Intent Status
const intent = await client.getIntent('intent_id_here');
console.log(`Status: ${intent.status}`);
console.log(`Gas used: ${intent.gas_used}`);
PoUW Market
Get Market Stats
const market = await client.getPouwMarket();
console.log(`Active provers: ${market.active_provers}`);
console.log(`Queue length: ${market.queue_length}`);
Error Handling
try {
const balance = await client.getBalance('invalid_address');
} catch (error) {
if (error instanceof Error) {
console.error(`Error: ${error.message}`);
}
}
Additional Resources
- Getting Started - Basic setup
- Smart Contracts with Mist - Contract development workflow
- NFT Standard - NFT implementation details
- Account Auth - Post-quantum signatures
- Performance - Benchmarks and optimization
For now, see Getting Started for basic usage.