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 🙏

© 2026 – Pkg Stats / Ryan Hefner

encifher-zec-sdk

v1.0.1

Published

Minimal SDK for converting ZEC to USDC using Near Intent API

Readme

Encifher ZEC to USDC SDK

A minimal TypeScript SDK for converting ZEC (Zcash) to USDC on Solana using the Near Intent API via ChainDefuser.

Features

  • 🚀 Simple Integration: Easy-to-use API for ZEC to USDC conversions
  • 💰 Quote Generation: Get real-time quotes for your ZEC to USDC swaps
  • 📊 Status Tracking: Monitor the progress of your transfers
  • 🔒 Type Safe: Full TypeScript support with comprehensive type definitions
  • Lightweight: Minimal dependencies and fast execution

Installation

npm install encifher-zec-usdc-sdk

Quick Start

import { EncifherZecUsdcSdk } from 'encifher-zec-sdk';

// Initialize the SDK
const sdk = new EncifherZecUsdcSdk({
  apiKey: 'your-chaindefuser-api-key'
});

// Get a quote for converting ZEC to USDC
const quote = await sdk.getQuote({
  amount: '1000000', // 1 ZEC in smallest unit (satoshis)
  recipient: '13QkxhNMrTPxoCkRdYdJ65tFuwXPhL5gLS2Z5Nr6gjRK', // Solana wallet address
  slippageTolerance: 100, // 1% slippage
  refundTo: 't1TL6sJHu9jrAa9vJ3syEcCCsF5mZazCDSp' // refund address in case bridge fails
});

console.log('Quote:', quote);

API Reference

Constructor

new EncifherZecUsdcSdk(config: SdkConfig)

Parameters

  • config.apiKey (string): Your ChainDefuser API key
  • config.baseUrl (string, optional): Custom API base URL (defaults to ChainDefuser API)

Methods

getQuote(request: ZecToUsdcQuoteRequest): Promise<CompatibleQuoteType>

Get a quote for converting ZEC to USDC.

Parameters
  • request.amount (string): Amount of ZEC to convert (in smallest unit)
  • request.recipient (string): Solana wallet address to receive USDC
  • request.slippageTolerance (number, optional): Slippage tolerance in basis points (default: 100 = 1%)
  • request.refundTo (string, optional): Optional refund address
Returns
{
  inputMint: string;           // ZEC asset identifier
  outputMint: string;          // USDC asset identifier
  inAmount: string;            // Input amount in smallest unit
  outAmount: string;           // Output amount in smallest unit
  slippageBps: number;         // Slippage in basis points
  router: string;              // Router identifier
  prioritizationFeeLamports: number; // Priority fee
  inUsdValue: number;          // Input value in USD
  outUsdValue: number;         // Output value in USD
  depositAddress: string;      // Deposit address for the transaction
}

getStatus(depositAddress: string): Promise<StatusResponse>

Get the status of a transfer using the deposit address from a quote.

Parameters
  • depositAddress (string): The deposit address from the quote response
Returns
{
  quoteResponse?: ChainDefuserQuoteResponse; // Original quote response
  status: 'PENDING' | 'KNOWN_DEPOSIT_TX' | 'COMPLETED' | 'FAILED' | 'REFUNDED';
  updatedAt: string; // Last update timestamp
  swapDetails?: {
    intentHashes?: string[];
    nearTxHashes?: string[];
    amountIn: string;
    amountInFormatted: string;
    amountInUsd: string;
    amountOut: string;
    amountOutFormatted: string;
    amountOutUsd: string;
    slippage: number;
    originChainTxHashes?: Array<{
      hash: string;
      explorerUrl: string;
    }>;
    destinationChainTxHashes?: Array<{
      hash: string;
      explorerUrl: string;
    }>;
    refundedAmount?: string;
    refundedAmountFormatted?: string;
    refundedAmountUsd?: string;
  };
}

Utility Methods

EncifherZecUsdcSdk.validateAmount(amount: string): boolean

Validate if a ZEC amount string is valid.

EncifherZecUsdcSdk.validateSolanaAddress(address: string): boolean

Validate if a Solana wallet address is properly formatted.

Usage Examples

Basic Quote Request

import { EncifherZecUsdcSdk } from 'encifher-zec-usdc-sdk';

const sdk = new EncifherZecUsdcSdk({
  apiKey: process.env.CHAINDEFUSER_API_KEY!
});

try {
  const quote = await sdk.getQuote({
    amount: '1000000', // 1 ZEC
    recipient: '13QkxhNMrTPxoCkRdYdJ65tFuwXPhL5gLS2Z5Nr6gjRK'
  });

  console.log(`Convert ${quote.inAmount} ZEC to ${quote.outAmount} USDC`);
  console.log(`Deposit to: ${quote.depositAddress}`);
  console.log(`Estimated USD value: $${quote.outUsdValue}`);
} catch (error) {
  console.error('Failed to get quote:', error);
}

Status Monitoring

async function monitorTransfer(depositAddress: string) {
  const sdk = new EncifherZecUsdcSdk({
    apiKey: process.env.CHAINDEFUSER_API_KEY!
  });

  let status = await sdk.getStatus(depositAddress);
  
  while (status.status !== 'COMPLETED' && status.status !== 'FAILED') {
    console.log(`Transfer status: ${status.status}`);
    
    if (status.swapDetails) {
      console.log(`Amount in: ${status.swapDetails.amountInFormatted} ZEC`);
      console.log(`Amount out: ${status.swapDetails.amountOutFormatted} USDC`);
    }
    
    // Wait 30 seconds before checking again
    await new Promise(resolve => setTimeout(resolve, 30000));
    status = await sdk.getStatus(depositAddress);
  }
  
  if (status.status === 'COMPLETED') {
    console.log('Transfer completed successfully!');
    if (status.swapDetails?.destinationChainTxHashes) {
      console.log('Transaction hash:', status.swapDetails.destinationChainTxHashes[0].hash);
    }
  } else {
    console.log('Transfer failed or was refunded');
  }
}

Input Validation

import { EncifherZecUsdcSdk } from 'encifher-zec-usdc-sdk';

function validateQuoteRequest(amount: string, recipient: string): boolean {
  if (!EncifherZecUsdcSdk.validateAmount(amount)) {
    console.error('Invalid ZEC amount');
    return false;
  }
  
  if (!EncifherZecUsdcSdk.validateSolanaAddress(recipient)) {
    console.error('Invalid Solana address');
    return false;
  }
  
  return true;
}

// Usage
if (validateQuoteRequest('1000000', '13QkxhNMrTPxoCkRdYdJ65tFuwXPhL5gLS2Z5Nr6gjRK')) {
  const quote = await sdk.getQuote({
    amount: '1000000',
    recipient: '13QkxhNMrTPxoCkRdYdJ65tFuwXPhL5gLS2Z5Nr6gjRK'
  });
}

Error Handling

The SDK throws SdkError objects with the following properties:

  • message: Human-readable error message
  • status: HTTP status code (if applicable)
  • code: Error code identifier
try {
  const quote = await sdk.getQuote(request);
} catch (error) {
  if (error.status === 401) {
    console.error('Invalid API key');
  } else if (error.status === 400) {
    console.error('Invalid request parameters');
  } else {
    console.error('Unexpected error:', error.message);
  }
}

Development

Building

npm run build

Testing

npm test

Linting

npm run lint

License

MIT

Support

For issues and questions, please check the documentation or contact support.