zetachain-sdk
v1.0.0
Published
Unified SDK for ZetaChain cross-chain integrations
Downloads
6
Maintainers
Readme
ZetaChain SDK
A comprehensive TypeScript/JavaScript SDK for ZetaChain's cross-chain infrastructure.
Installation
npm install zetachain-sdkQuick Start
import ZetaChainSDK from 'zetachain-sdk';
const sdk = new ZetaChainSDK({
apiKey: 'your-api-key-here'
});
// Get balances across multiple networks
const balances = await sdk.getBalances('0x742d35Cc6C7486B4E1f5312b2E6a9F9E2A91D1b0', ['ethereum', 'polygon']);
// Create a new account
const account = await sdk.createAccount('MyWallet', 'evm');
// Send a cross-chain transaction
const transaction = await sdk.sendTransaction({
from: '0xfrom...',
to: '0xto...',
amount: '1000000',
network: 'ethereum'
});Features
- ✅ Account Management - Create, list, and manage blockchain accounts
- ✅ Balance Queries - Check balances across multiple networks
- ✅ Cross-Chain Transactions - Send transactions between different blockchains
- ✅ Network Information - Get real-time network status and details
- ✅ Address Validation - Validate addresses for different networks
- ✅ Gas Estimation - Estimate transaction fees
- ✅ Unit Conversion - Convert between different units
- ✅ Bridge Operations - Bridge assets between chains
Supported Networks
- Ethereum
- Polygon
- BSC (Binance Smart Chain)
- Solana
- Sui
- Bitcoin
- TON
API Reference
Account Management
// List all accounts
const accounts = await sdk.listAccounts();
// Create a new account
const account = await sdk.createAccount('wallet-name', 'evm');
// Delete an account
await sdk.deleteAccount('wallet-name');Balance Operations
// Get balances for multiple networks
const balances = await sdk.getBalances(address, ['ethereum', 'polygon']);
// Get balance for a single network
const balance = await sdk.getBalance(address, 'ethereum');Transaction Operations
// Send a transaction
const tx = await sdk.sendTransaction({
from: '0xfrom...',
to: '0xto...',
amount: '1000000',
network: 'ethereum'
});
// Estimate gas costs
const gasEstimate = await sdk.estimateGas('ethereum', 'transfer');Network Operations
// Get network information
const networkInfo = await sdk.getNetworkInfo('ethereum');
// Get all supported networks
const networks = await sdk.getSupportedNetworks();Cross-Chain Operations
// Get cross-chain quote
const quote = await sdk.getCrossChainQuote('ethereum', 'polygon', '1000000');
// Bridge assets between chains
const bridgeTx = await sdk.bridgeAssets('ethereum', 'polygon', '1000000', fromAddress, toAddress);Utility Methods
// Validate an address
const isValid = await sdk.validateAddress('0x...', 'ethereum');
// Convert units
const converted = await sdk.convertUnits('1', 'ether', 'wei');TypeScript Support
The SDK is written in TypeScript and includes full type definitions:
import ZetaChainSDK, { Account, Balance, Transaction, NetworkInfo } from 'zetachain-sdk';Error Handling
try {
const balances = await sdk.getBalances(address);
} catch (error) {
console.error('ZetaChain API error:', error.message);
}Configuration
const sdk = new ZetaChainSDK({
apiKey: 'your-api-key',
baseUrl: 'https://custom-endpoint.com' // Optional, defaults to official endpoint
});License
MIT
