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

@mayaprotocol/zcash-js

v1.0.7

Published

Zcash JavaScript library for Maya Protocol - Build and sign Zcash transparent transactions with memo support

Readme

@mayaprotocol/zcash-js

A JavaScript/TypeScript library for interacting with Zcash nodes, designed for Maya Protocol integration.

Installation

npm install @mayaprotocol/zcash-js

Features

  • Build and sign Zcash transparent transactions
  • Support for memo fields in transactions
  • UTXO management
  • Fee calculation
  • TypeScript support
  • Works with Zcash mainnet and testnet

Usage

Basic Setup

import { Config, buildTx, signAndFinalize, sendRawTransaction, getUTXOS } from '@mayaprotocol/zcash-js';

const config: Config = {
  server: {
    host: 'http://localhost:8232', // Your Zcash node URL
    user: 'your-rpc-user',
    password: 'your-rpc-password'
  },
  mainnet: true // or false for testnet
};

Building and Sending a Transaction

// Get UTXOs for the source address
const utxos = await getUTXOS('t1SourceAddress...', config);

// Build the transaction
const tx = await buildTx(
  0, // current block height
  't1SourceAddress...', // from address
  't1DestinationAddress...', // to address
  1000000, // amount in satoshis
  utxos,
  false // is this a memo transaction?
);

// Sign the transaction
const signedTx = await signAndFinalize(
  tx.height,
  'your-private-key-hex', // private key for source address
  tx.inputs,
  tx.outputs
);

// Send the transaction
const txid = await sendRawTransaction(signedTx, config);
console.log('Transaction ID:', txid);

Sending a Transaction with Memo

const tx = await buildTx(
  0,
  't1SourceAddress...',
  't1DestinationAddress...',
  1000000,
  utxos,
  false,
  'swap:cacao:maya1a7gg93dgwlulsrqf6qtage985ujhpu068zllw7' // memo text
);

Address Generation

import { pkToAddr, mainnetPrefix, testnetPrefix } from '@mayaprotocol/zcash-js';

// Generate address from public key
const publicKey = Buffer.from('02aa7ef4b1958837763303a675dea8f63eaf264494072f086acdbc78d0decb0d0f', 'hex');
const address = pkToAddr(publicKey, Buffer.from(testnetPrefix));
console.log('Address:', address); // tmUzzEDRjvE3QC8RBUFD7DTi5LLL4zAEvKW

Address Validation

import { isValidAddr, mainnetPrefix, testnetPrefix } from '@mayaprotocol/zcash-js';

// Validate testnet address
const isValid = isValidAddr('tmUzzEDRjvE3QC8RBUFD7DTi5LLL4zAEvKW', Buffer.from(testnetPrefix));
console.log('Is valid testnet address:', isValid); // true

// Validate mainnet address
const isMainnetValid = isValidAddr('t1R97mnhVqcE7Yq8p7yL4E29gy8etq9V9pG', Buffer.from(mainnetPrefix));
console.log('Is valid mainnet address:', isMainnetValid); // true

API Reference

Types

Config

interface Config {
  server: {
    host: string;    // Zcash RPC endpoint URL
    user: string;    // RPC username
    password: string; // RPC password
  };
  mainnet: boolean; // true for mainnet, false for testnet
}

UTXO

interface UTXO {
  txid: string;
  vout: number;
  amount: number;
  scriptPubKey: {
    hex: string;
    addresses: string[];
  };
  confirmations: number;
}

Functions

  • getUTXOS(address: string, config: Config): Promise<UTXO[]> - Get unspent transaction outputs for an address
  • buildTx(height: number, from: string, to: string, amount: number, utxos: UTXO[], extraFeeForMemo: boolean, memo?: string): Promise<BuildTxResult> - Build a transaction
  • signAndFinalize(height: number, privateKey: string, inputs: Input[], outputs: Output[]): Promise<Buffer> - Sign and finalize a transaction
  • sendRawTransaction(txb: Buffer, config: Config): Promise<string> - Send a signed transaction
  • pkToAddr(publicKey: Buffer, prefix: Buffer): string - Generate address from public key
  • isValidAddr(address: string, prefix: Buffer): boolean - Validate an address
  • waitForTransaction(txid: string, config: Config, maxAttempts?: number): Promise<void> - Wait for transaction confirmation

Requirements

  • Node.js >= 14
  • A running Zcash node with RPC enabled

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues and feature requests, please use the GitLab issue tracker.