npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@conduit-ucpi/web3-sdk

v0.0.6-alpha

Published

A lightweight JavaScript/TypeScript SDK for web3 operations on the Conduit UCPI Avalanche subnet

Readme

Conduit UCPI Web3 SDK

A lightweight JavaScript/TypeScript SDK that provides a simple interface for web3 operations on the Conduit UCPI Avalanche subnet. The SDK handles Web3Auth authentication, service communication, and transaction signing while abstracting all blockchain complexity from the client.

Features

  • 🔐 Web3Auth Integration - Seamless wallet authentication
  • 📝 Contract Operations - Deploy and interact with smart contracts
  • 💰 On-Ramp Services - Fiat to crypto conversion
  • 👛 Wallet Management - Balance queries and transaction history
  • One-Click Deployment - Complete contract deployment with funding
  • 🎣 React Hooks - Ready-to-use React components
  • 🛡️ Type Safety - Full TypeScript support
  • 🔄 Error Handling - Comprehensive error management

Installation

npm install @conduit-ucpi/web3-sdk
# or
yarn add @conduit-ucpi/web3-sdk

Quick Start

Basic Usage

import { ConduitSDK } from '@conduit-ucpi/web3-sdk';

const sdk = new ConduitSDK({
  apiKey: 'sk_live_your_api_key_here',
  environment: 'production',
  web3authClientId: 'BH_your_web3auth_client_id'
});

// Connect wallet
const address = await sdk.connect();
console.log('Connected:', address);

// Deploy an ERC20 token
const token = await sdk.deployContract('erc20', {
  name: 'My Token',
  symbol: 'MTK',
  decimals: 18,
  initialSupply: '1000000'
});
console.log('Token deployed at:', token.contractAddress);

One-Click Contract Deployment with Funding

// Complete flow with automatic funding
const result = await sdk.deployContractWithFunding('erc20', {
  name: 'My Business Token',
  symbol: 'MBT',
  decimals: 18,
  initialSupply: '1000000'
}, 50, { // $50 funding
  onrampProvider: 'moonpay',
  onStepComplete: (step, data) => {
    console.log(`✅ ${step}:`, data);
  },
  onStepError: (step, error) => {
    console.error(`❌ ${step}:`, error);
  }
});

if (result.success) {
  console.log('🎉 Contract deployed successfully!');
  console.log('Contract Address:', result.contractAddress);
  console.log('Transaction Hash:', result.transactionHash);
}

React Integration

import React from 'react';
import { useConduitSDK, useBalance, useAllBalances } from '@conduit-ucpi/web3-sdk';

function App() {
  const { sdk, isConnected, address, connect, disconnect } = useConduitSDK({
    apiKey: 'sk_live_your_api_key_here',
    environment: 'production',
    web3authClientId: 'BH_your_web3auth_client_id'
  });

  const { balance } = useBalance(sdk);
  const { balances } = useAllBalances(sdk);

  return (
    <div>
      {!isConnected ? (
        <button onClick={connect}>Connect Wallet</button>
      ) : (
        <div>
          <p>Connected: {address}</p>
          <p>Balance: {balance?.balanceFormatted} {balance?.symbol}</p>
          <button onClick={disconnect}>Disconnect</button>
        </div>
      )}
    </div>
  );
}

API Reference

Configuration

interface ConduitSDKConfig {
  apiKey: string;
  environment: 'production' | 'staging' | 'development';
  web3authClientId: string;
  apiBaseUrl?: string;
  timeout?: number;
  retryAttempts?: number;
  enableLogging?: boolean;
}

Authentication

// Connect wallet
const address: string = await sdk.connect();

// Disconnect wallet
await sdk.disconnect();

// Check connection status
const isConnected: boolean = sdk.isConnected();

// Get user address
const address: string | null = sdk.getAddress();

// Get session token
const token: string | null = sdk.getSessionToken();

Contract Operations

// Deploy contract
const result: DeploymentResult = await sdk.deployContract(type, params);

// Call contract function
const result: TransactionResult = await sdk.callContract(
  address,
  functionName,
  args,
  options
);

// Read from contract
const data: any = await sdk.readContract(
  address,
  functionName,
  args,
  abi
);

On-Ramp Operations

// Buy USDC with fiat
const result: OnRampResult = await sdk.buyUSDC(amount, options);

// Get available providers
const providers: OnRampProvider[] = await sdk.getOnRampProviders();

// Get quote
const quote: OnRampQuote = await sdk.getOnRampQuote(amount, currency, provider);

// Check status
const status: OnRampStatus = await sdk.getOnRampStatus(sessionId);

// Get history
const history: OnRampTransaction[] = await sdk.getOnRampHistory();

Wallet Operations

// Get token balance
const balance: TokenBalance = await sdk.getBalance(tokenAddress);

// Get all balances
const summary: WalletSummary = await sdk.getAllBalances();

// Get transaction history
const history: TransactionHistory = await sdk.getTransactionHistory(options);

// Get transaction status
const status: TransactionStatus = await sdk.getTransactionStatus(txHash);

Utility Operations

// Get nonce
const nonce: number = await sdk.getNonce();

// Estimate gas
const gasEstimate: string = await sdk.estimateGas(to, data, value);

// Get token info
const info: TokenInfo = await sdk.getTokenInfo(tokenAddress);

// Detect tokens
const tokens: TokenInfo[] = await sdk.detectTokens();

Contract Types

ERC20 Token

const erc20Params: ERC20Params = {
  name: 'My Token',
  symbol: 'MTK',
  decimals: 18,
  initialSupply: '1000000000000000000000000' // 1M tokens
};

ERC721 NFT

const erc721Params: ERC721Params = {
  name: 'My NFT Collection',
  symbol: 'MNC',
  baseTokenURI: 'https://api.example.com/metadata/'
};

ERC1155 Multi-Token

const erc1155Params: ERC1155Params = {
  name: 'My Multi-Token Collection',
  symbol: 'MMC',
  baseTokenURI: 'https://api.example.com/metadata/'
};

React Hooks

useConduitSDK

const { sdk, isConnected, address, connect, disconnect } = useConduitSDK(config);

useBalance

const { balance, isLoading, error, refetch } = useBalance(sdk, tokenAddress);

useAllBalances

const { balances, isLoading, error, refetch } = useAllBalances(sdk);

useTransactionHistory

const { history, isLoading, error, loadMore, hasMore } = useTransactionHistory(sdk, options);

useOnRamp

const { buyUSDC, getProviders, getQuote, isLoading, error } = useOnRamp(sdk);

Error Handling

The SDK provides comprehensive error handling with specific error types:

import { 
  ConduitSDKError, 
  AuthenticationError, 
  NetworkError, 
  ContractError 
} from '@conduit-ucpi/web3-sdk';

try {
  await sdk.deployContract('erc20', params);
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error('Authentication failed:', error.message);
  } else if (error instanceof ContractError) {
    console.error('Contract operation failed:', error.message);
  } else if (error instanceof NetworkError) {
    console.error('Network error:', error.message);
  }
}

Utility Functions

Validation

import { validateAddress, validateAmount } from '@conduit-ucpi/web3-sdk';

const isValidAddress = validateAddress('0x1234...');
const isValidAmount = validateAmount('100.50');

Formatting

import { formatAddress, formatBalance, formatUSDValue } from '@conduit-ucpi/web3-sdk';

const shortAddress = formatAddress('0x1234567890abcdef...'); // 0x1234...cdef
const formattedBalance = formatBalance('1000000000000000000', 18); // 1.0
const usdValue = formatUSDValue('1234.56'); // $1,234.56

Development

Building

npm run build

Development Mode

npm run dev

Testing

npm test

Linting

npm run lint

License

MIT License - see LICENSE file for details.

Support

For support and questions, please contact:

  • Email: [email protected]
  • Documentation: https://docs.conduit-ucpi.com
  • GitHub Issues: https://github.com/conduit-ucpi/web3-sdk/issues