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

alkahest-ts

v1.1.2

Published

TypeScript SDK for [Alkahest](https://github.com/arkhai-io/alkahest), a library and ecosystem of contracts for conditional peer-to-peer escrow. Built on [viem](https://viem.sh/).

Readme

alkahest-ts

TypeScript SDK for Alkahest, a library and ecosystem of contracts for conditional peer-to-peer escrow. Built on viem.

Installation

npm install alkahest-ts viem

Usage

Initialize a client with a viem wallet. The client auto-detects contract addresses for supported chains.

import { makeClient } from "alkahest-ts";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount, nonceManager } from "viem/accounts";
import { baseSepolia } from "viem/chains";

const client = makeClient(
  createWalletClient({
    account: privateKeyToAccount(process.env.PRIVKEY as `0x${string}`, {
      nonceManager,
    }),
    chain: baseSepolia,
    transport: http(process.env.RPC_URL as string),
  }),
);

Examples

Trade ERC20 for ERC20

Uses escrow clients to create escrows, and atomic payment utilities to settle compatible escrows atomically.

import { parseUnits } from "viem";

const usdc = "0x036CbD53842c5426634e7929541eC2318f3dCF7e" as const;
const eurc = "0x808456652fdb597867f38412077A9182bf77359F" as const;

// Alice: approve escrow and deposit 10 USDC, demanding 10 EURC
const escrow = await clientAlice.erc20.escrow.default.approveAndCreate(
  { address: usdc, value: parseUnits("10", 6) },
  { arbiter: erc20PaymentAddress, demand: encodedErc20PaymentDemand },
  0n, // no expiration
);

// Bob: approve atomic payment utilities and fulfill the escrow by paying 10 EURC
await clientBob.erc20.util.approve(
  { address: eurc, value: parseUnits("10", 6) },
  "atomicPayment",
);
const payment = await clientBob.erc20.payment.payErc20AndCollect(
  escrow.attested.uid,
);

Trade ERC20 for custom demand

Uses TrustedOracleArbiter to delegate fulfillment validation to an off-chain oracle, and StringObligation for the fulfillment.

import { encodeAbiParameters, parseAbiParameters, parseUnits } from "viem";

const usdc = "0x036CbD53842c5426634e7929541eC2318f3dCF7e" as const;

// Encode the inner demand data (application-specific; agreed upon by buyer and seller)
const innerDemand = encodeAbiParameters(
  parseAbiParameters("(string query)"),
  [{ query: "capitalize hello world" }],
);

// Encode the TrustedOracleArbiter demand, naming Charlie as the oracle
const demand = clientAlice.arbiters.general.trustedOracle.encodeDemand({
  oracle: charlieAddress,
  data: innerDemand,
});

// Alice: deposit USDC into escrow with the custom demand
const escrow = await clientAlice.erc20.escrow.default.approveAndCreate(
  { address: usdc, value: parseUnits("100", 6) },
  {
    arbiter: clientAlice.contractAddresses.trustedOracleArbiter,
    demand,
  },
  BigInt(Math.floor(Date.now() / 1000) + 86400), // 24h expiration
);

// Bob: fulfill the demand with a StringObligation attestation
const fulfillment = await clientBob.stringObligation.doObligation(
  "HELLO WORLD", // the computed result
  undefined,     // schema (optional)
  escrow.attested.uid, // reference to the escrow being fulfilled
);

// Charlie: arbitrate the result (or use arbitrateMany for event-driven arbitration)
await clientCharlie.arbiters.general.trustedOracle.arbitrate(
  fulfillment.attested.uid,
  demand,
  true, // decision: valid
);

// Bob: collect the escrow
await clientBob.erc20.escrow.default.collect(
  escrow.attested.uid,
  fulfillment.attested.uid,
);

// Alice: wait for fulfillment (useful if running concurrently)
const result = await clientAlice.waitForFulfillment(
  clientAlice.contractAddresses.erc20EscrowObligation,
  escrow.attested.uid,
);

See the docs for more detailed guides, including composing arbiters and building off-chain oracle validators.

Development

Running Tests with Anvil

Tests run against an Anvil fork of Base Sepolia.

  1. Set up your environment:

    export RPC_URL=<your-base-sepolia-rpc-url>
  2. Run tests using Anvil fork:

    bun run test:anvil
  3. Run a specific test file:

    bun run test:anvil:single tests/tradeErc20.test.ts
  4. Start Anvil fork in a separate terminal (for debugging):

    bun run anvil

Local Development Client

import { createWalletClient, http } from "viem";
import { privateKeyToAccount, nonceManager } from "viem/accounts";
import { makeClient } from "alkahest-ts";
import { anvilChain, ANVIL_ACCOUNTS } from "./path/to/anvil";

const client = makeClient(
  createWalletClient({
    account: privateKeyToAccount(ANVIL_ACCOUNTS.ALICE.privateKey, {
      nonceManager,
    }),
    chain: anvilChain,
    transport: http("http://localhost:8545"),
  }),
);