STATUS: PROPOSED API ONLY
This SDK is not yet implemented. The code below shows the intended API design. No npm package exists. Integration requires using ord CLI + Spark SDK separately until this is built.
Installation
# PROPOSED (not yet published):
# npm install @sparkle-protocol/sdk
# CURRENT REALITY:
# No npm package exists. Use ord CLI directly for inscriptions.
# Use @buildonspark/spark-sdk separately for Lightning payments.
try {
const nft = await sparkle.createNFT({...});
} catch (error) {
if (error.code === 'INSUFFICIENT_FUNDS') {
console.error('Not enough BTC for inscription');
} else if (error.code === 'INVALID_LAYER') {
console.error('Layer inscription not found');
} else if (error.code === 'LIGHTNING_OFFLINE') {
console.error('Lightning node not reachable');
}
}
Database Schema
-- Required tables for indexer
CREATE TABLE sparkle_nfts (
id SERIAL PRIMARY KEY,
inscription_id VARCHAR(66) UNIQUE NOT NULL,
block_height INTEGER NOT NULL,
metadata JSONB NOT NULL,
lightning_enabled BOOLEAN DEFAULT false,
owner_address VARCHAR(62),
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE sparkle_layers (
id SERIAL PRIMARY KEY,
inscription_id VARCHAR(66) UNIQUE NOT NULL,
layer_type VARCHAR(50) NOT NULL,
file_hash VARCHAR(64) NOT NULL,
file_size INTEGER NOT NULL,
created_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE sparkle_trades (
id SERIAL PRIMARY KEY,
nft_id VARCHAR(66) NOT NULL,
seller_address VARCHAR(62) NOT NULL,
buyer_address VARCHAR(62) NOT NULL,
price_sats BIGINT NOT NULL,
lightning_invoice TEXT,
payment_hash VARCHAR(64),
status VARCHAR(20) NOT NULL,
created_at TIMESTAMP DEFAULT NOW(),
completed_at TIMESTAMP
);
CREATE INDEX idx_sparkle_owner ON sparkle_nfts(owner_address);
CREATE INDEX idx_sparkle_lightning ON sparkle_nfts(lightning_enabled);
CREATE INDEX idx_trade_status ON sparkle_trades(status);