A monorepo containing TypeScript SDKs for routing assets to and from Zcash. Built with pnpm workspaces, supporting both ESM and CommonJS, and compatible with Node.js and browsers.
Live demos:
- https://zcash.nu.fi - Full demo with mnemonic input (build of
packages/example-app) - https://zcash-hackathon.nu.fi - NUFI wallet integration
These are fully functional, production-grade implementations:
- β Live blockchain integration - Real swaps on Solana and Zcash mainnet
- β End-to-end transactions - Complete deposit to withdrawal flow
- β Professional UI - Modern interface with real-time status tracking
The SDK is designed with a modular architecture that separates concerns and makes it easy to extend support for new assets and wallet types:
The @zcash-router-sdk/core package handles all the logic for managing swaps to and from Zcash. Built on NEAR intents, it provides:
- Swap orchestration and state management
- Integration with swap APIs
- Quote fetching and execution tracking
- Status monitoring and event callbacks
Account packages implement the AccountFull and AccountAddressOnly interfaces defined in the core package, providing blockchain-specific functionality:
-
@zcash-router-sdk/zcash-account-mnemonic- Zcash account management with mnemonic support- Supports signing of shielded transactions
- Manages Zcash wallet state and synchronization
- Handles transparent and shielded addresses
-
@zcash-router-sdk/solana-account-mnemonic- Solana account management with mnemonic support- Native SOL balance fetching and transaction signing
- Mnemonic-based key derivation
The architecture makes it easy to add new packages for:
- Other blockchain assets (Ethereum, Bitcoin, etc.)
- Hardware wallets (Ledger, Trezor, etc.)
- Extension wallets (MetaMask, Phantom, etc.)
- Other key management methods (WIF, private keys, etc.)
Simply implement the AccountFull or AccountAddressOnly interface from the core package, and your new account type will work seamlessly with the swap routing logic.
@zcash-router-sdk/core- Core swap and routing logic@zcash-router-sdk/zcash-account-mnemonic- Zcash account management with mnemonic support@zcash-router-sdk/solana-account-mnemonic- Solana account management with mnemonic supportexample-app- Example React application demonstrating SDK usage
- Node.js 18+
- pnpm (Install with
npm install -g pnpm)
# Install dependencies for all packages
pnpm install
# Build all packages
pnpm build
# Run tests for all packages
pnpm testThe example-app is a React application that demonstrates how to use the Zcash Router SDK. It includes:
- Route to Zcash: Swap assets from Solana (SOL) to Zcash (ZEC)
- Route from Zcash: Swap assets from Zcash to Solana
- Real-time swap status tracking
- Clean, modern UI with Material-UI and Tailwind CSS
To run the example app:
# From the root directory
pnpm --filter @zcash-router-sdk/example-app run dev
# Or navigate to the example-app directory
cd packages/example-app
pnpm devThe app will be available at http://localhost:3000. See the example-app README for more details.
This is a fully functional, production-ready implementation:
- β Live blockchain integration - Real swaps on Solana and Zcash mainnet
- β End-to-end transactions - Complete deposit to withdrawal flow
- β Modular architecture - Extensible SDK design for adding new chains
- β Professional UI - Modern interface with real-time status tracking
- β Comprehensive error handling - Graceful failure recovery
- β Full type safety - TypeScript throughout with comprehensive testing
Not a mockup or prototype - this actually works.
π₯ View Live Demo | π» Try It Yourself
Run these commands from the root directory:
# Build all packages
pnpm build
# Development mode (watch)
pnpm dev
# Run tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run tests with coverage
pnpm test:coverage
# Lint all packages
pnpm lint
# Fix linting issues
pnpm lint:fix
# Format code
pnpm format
# Check formatting
pnpm format:check
# Type check all packages
pnpm typecheck
# Clean build artifacts
pnpm clean# Build a specific package
pnpm --filter @zcash-router-sdk/core build
# Test a specific package
pnpm --filter @zcash-router-sdk/core test
# Run dev mode for a specific package
pnpm --filter @zcash-router-sdk/core dev
# Run the example app
pnpm --filter @zcash-router-sdk/example-app run devTo add support for a new blockchain or wallet type:
-
Create a new directory in
packages/:mkdir packages/new-account-package
-
Create a
package.jsonwith the name@zcash-router-sdk/new-account-package:{ "name": "@zcash-router-sdk/new-account-package", "version": "0.1.0", "dependencies": { "@zcash-router-sdk/core": "workspace:*" } } -
Implement the
AccountFullorAccountAddressOnlyinterface from@zcash-router-sdk/core:import type { AccountFull } from '@zcash-router-sdk/core'; export class NewAccount implements AccountFull { readonly type = 'full' as const; readonly asset: RouteAsset; async getAddress(): Promise<string> { /* ... */ } async getBalance(): Promise<bigint> { /* ... */ } assetToBaseUnits(amount: string): bigint { /* ... */ } async sendDeposit(params: { address: string; amount: string }): Promise<string> { /* ... */ } }
-
Install dependencies from the root:
pnpm install
-
Your new account type will now work with
routeToZcash()androuteFromZcash()functions!
To use one package within another:
{
"dependencies": {
"@zcash-router-sdk/core": "workspace:*"
}
}zcash-router-sdk/
βββ packages/
β βββ core/ # Core swap and routing logic
β βββ zcash-account-mnemonic/ # Zcash account management
β βββ solana-account-mnemonic/ # Solana account management
β βββ example-app/ # Example React app
βββ .eslintrc.cjs # Shared ESLint config
βββ .prettierrc # Shared Prettier config
βββ pnpm-workspace.yaml # pnpm workspace config
βββ package.json # Root package with workspace scripts
βββ README.md
All packages use Vitest for testing. Tests are located in the tests/ directory of each package.
# Run all tests
pnpm test
# Run tests with coverage
pnpm test:coverage
# Run tests in watch mode
pnpm test:watchThis monorepo uses:
- TypeScript for type safety
- ESLint for code linting
- Prettier for code formatting
- Vitest for testing
Configuration files are shared across all packages from the root directory.
- tsup - Fast bundler built on esbuild
- TypeScript - Type checking and declarations
- pnpm - Fast, efficient package manager with workspace support
To publish a package:
-
Navigate to the package directory:
cd packages/core -
Update the version in
package.json -
Run the prepublish checks:
pnpm run prepublishOnly
-
Publish to npm:
pnpm publish
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
MIT