celeriz-sdk
v1.0.7
Published
A modern, type-safe SDK for blockchain wallet management and transactions
Maintainers
Readme
Celeriz SDK
A modern, type-safe SDK for blockchain wallet management, transactions, and fiat on/off ramping.
Documentation • Installation • Quick Start • API Reference • Examples
Installation
# Using npm
npm install celeriz
# Using yarn
yarn add celeriz
# Using pnpm
pnpm add celerizQuick Start
import { Celeriz } from 'celeriz';
// Initialize the SDK
const celeriz = new Celeriz({
apiKey: 'your-api-key'
});
// Create a new wallet
const wallet = await celeriz.createWallet({
network: 'Ethereum',
name: 'My Wallet'
});
console.log('Wallet created:', wallet.address);Documentation
Initialization
const celeriz = new Celeriz({
apiKey: string; // Your Celeriz API key
baseUrl?: string; // Optional, defaults to 'https://api.celeriz.com'
});Wallet Management
Create Wallet
const wallet = await celeriz.createWallet({
network: 'Ethereum' | 'Base' | 'ArbitrumOne' | 'Optimism' | 'Polygon';
name?: string; // Optional wallet name
clientId?: string; // Optional client identifier
tags?: string[]; // Optional tags for organization
});Get Wallet
const wallet = await celeriz.getWallet(walletId: string);List Wallets
const wallets = await celeriz.listWallets({
limit?: number; // Number of wallets to return
cursor?: string; // Pagination cursor
externalId?: string; // Filter by external ID
});Transactions
Sign Message
const signature = await celeriz.signMessage({
walletId: string;
message: string;
});Sign Transaction
const signedTx = await celeriz.signTransaction({
walletId: string;
transaction: string;
});Broadcast Transaction
const txHash = await celeriz.broadcastTransaction({
walletId: string;
transaction: string;
kind?: 'Json'; // Optional transaction kind
externalId?: string; // Optional external identifier
});Balance
Get Wallet Balance
const balances = await celeriz.getWalletBalance({
walletId: string;
});Fiat On/Off Ramping
Get Onramp Quotes
const quotes = await celeriz.getOnrampQuotes({
sourceCurrency: string; // Fiat currency (e.g., 'USD')
destinationCurrency: string; // Crypto currency (e.g., 'ETH')
amount: string; // Amount in source currency
});Create Onramp Order
const order = await celeriz.createOnrampOrder({
quoteId: string;
walletId: string;
sourceCurrency: string;
destinationCurrency: string;
sourceAmount: string;
destinationAmount: string;
paymentMethod: 'card' | 'bank_transfer';
redirectUrl?: string;
metadata?: Record<string, any>;
});Get Onramp Order Status
const order = await celeriz.getOnrampOrder(orderId: string);Get Offramp Quotes
const quotes = await celeriz.getOfframpQuotes({
sourceCurrency: string; // Crypto currency (e.g., 'ETH')
destinationCurrency: string; // Fiat currency (e.g., 'USD')
amount: string; // Amount in source currency
});Create Offramp Order
const order = await celeriz.createOfframpOrder({
quoteId: string;
walletId: string;
sourceCurrency: string;
destinationCurrency: string;
sourceAmount: string;
destinationAmount: string;
destinationAddress: string; // Bank account or other fiat destination
metadata?: Record<string, any>;
});Get Offramp Order Status
const order = await celeriz.getOfframpOrder(orderId: string);Examples
Creating and Managing Wallets
// Create a new wallet
const wallet = await celeriz.createWallet({
network: 'Ethereum',
name: 'Trading Wallet',
tags: ['trading', 'active']
});
// Get wallet details
const details = await celeriz.getWallet(wallet.id);
// List all wallets
const wallets = await celeriz.listWallets({
limit: 10
});Transaction Operations
// Sign a message
const signature = await celeriz.signMessage({
walletId: wallet.id,
message: 'Hello, Blockchain!'
});
// Sign and broadcast a transaction
const signedTx = await celeriz.signTransaction({
walletId: wallet.id,
transaction: '0x...'
});
const txHash = await celeriz.broadcastTransaction({
walletId: wallet.id,
transaction: signedTx
});Fiat On/Off Ramping
// Get onramp quotes for converting USD to ETH
const quotes = await celeriz.getOnrampQuotes({
sourceCurrency: 'USD',
destinationCurrency: 'ETH',
amount: '100'
});
// Create an onramp order
const order = await celeriz.createOnrampOrder({
quoteId: quotes[0].id,
walletId: wallet.id,
sourceCurrency: 'USD',
destinationCurrency: 'ETH',
sourceAmount: '100',
destinationAmount: '0.05',
paymentMethod: 'card',
redirectUrl: 'https://your-app.com/callback'
});
// Get offramp quotes for converting ETH to USD
const offrampQuotes = await celeriz.getOfframpQuotes({
sourceCurrency: 'ETH',
destinationCurrency: 'USD',
amount: '0.1'
});
// Create an offramp order
const offrampOrder = await celeriz.createOfframpOrder({
quoteId: offrampQuotes[0].id,
walletId: wallet.id,
sourceCurrency: 'ETH',
destinationCurrency: 'USD',
sourceAmount: '0.1',
destinationAmount: '200',
destinationAddress: '0x...' // Bank account or other fiat destination
});Error Handling
All methods throw errors with descriptive messages:
try {
const wallet = await celeriz.createWallet({
network: 'Ethereum',
name: 'My Wallet'
});
} catch (error) {
console.error('Failed to create wallet:', error.message);
}Supported Networks
- Ethereum
- Base
- Arbitrum One
- Optimism
- Polygon
Development
# Install dependencies
npm install
# Build
npm run build
# Run tests
npm test
# Lint
npm run lint
# Format code
npm run formatLicense
MIT
Support
- Email: [email protected]
- Discord: Join our community
- Documentation: Full API Reference
