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

chainsig.js

v1.1.14

Published

ChainSig Library

Readme

Chainsig.js

A TypeScript library for creating transactions for different chains and signing them with NEAR's MPC (Multi-party Computation)service.

Overview

This library provides a unified interface for interacting with different blockchain networks through a common set of methods. It uses MPC for secure key management and transaction signing.

Features

  • Multi-Chain Support: Built-in support for EVM chains, Bitcoin, Cosmos, Solana, Aptos, and SUI networks
  • Unified Interface: Common API across all supported chains
  • MPC Integration: Secure key management and transaction signing
  • Type Safety: Full TypeScript support with comprehensive type definitions
  • Modular Design: Easy to extend with new chain implementations
  • Secure: No private keys stored or transmitted

Supported Chains

The library provides chain adapters for the following blockchain networks:

  • EVM Chains: Ethereum, BSC, Polygon, Arbitrum, Optimism, and other EVM-compatible networks
  • Bitcoin: Bitcoin mainnet and testnet with P2WPKH transaction support
  • Cosmos: Cosmos Hub, Osmosis, and other Cosmos SDK-based chains
  • Solana: High-performance blockchain with native token transfers
  • Aptos: Move-based blockchain with Ed25519 signature support
  • SUI: Move-based blockchain with Ed25519 signature support
  • XRP Ledger: XRP mainnet, testnet, and devnet with native XRP transfers

Each chain adapter provides a unified interface for:

  • Address and public key derivation
  • Balance checking
  • Transaction preparation and signing
  • Transaction broadcasting

Installation

npm install chainsig.js
# or
yarn add chainsig.js
# or
pnpm add chainsig.js

Docs and Examples

Examples for sending transfers and function calls with chainsig.js via a NEAR wallet can be found in the near-multichain repo, along with in depth documentation in the NEAR docs.

Examples for sending transfers with chainsig.js via near-api-js/near-js can be found in the examples folder.

Full typedocs for the library can be found here.

Using the Library

Because of underlying dependencies, this library is a Commonjs project. You may need to configure your projects to use this library.

Here are simple examples in TypeScript and JavaScript.

Quick Example

import { chainAdapters, contracts } from "chainsig.js";
import { KeyPair, type KeyPairString } from "@near-js/crypto";
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";

// Initialize NEAR connection with credentials from environment
const accountId = process.env.NEAR_ACCOUNT_ID;
const privateKey = process.env.NEAR_PRIVATE_KEY as KeyPairString;

if (!accountId || !privateKey) {
  throw new Error(
    "NEAR_ACCOUNT_ID and NEAR_PRIVATE_KEY must be set in environment",
  );
}

const keypair = KeyPair.fromString(privateKey);

const contract = new contracts.near.ChainSignatureContract({
  networkId: "testnet",
  contractId: "v1.signer-prod.testnet",
  accountId,
  keypair,
});

const publicClient = createPublicClient({
  chain: mainnet,
  transport: http(),
});

const evmChain = new chainAdapters.evm.EVM({
  publicClient,
  contract,
});

// Derive address and public key
const { address, publicKey } = await evmChain.deriveAddressAndPublicKey(
  accountId,
  "any_string",
);

// Check balance
const { balance, decimals } = await evmChain.getBalance(address);

// Create and sign transaction
const { transaction, hashesToSign } =
  await evmChain.prepareTransactionForSigning({
    from: "0x...",
    to: "0x...",
    value: 1n,
  });

// Sign with MPC
const signature = await contract.sign({
  payload: hashesToSign[0].payload,
  path: "any_string",
  key_version: 0,
});

// Add signature
const signedTx = evmChain.finalizeTransactionSigning({
  transaction,
  rsvSignatures: [signature],
});

// Broadcast transaction
const txHash = await evmChain.broadcastTx(signedTx);