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

@perkos/contracts-escrow

v1.0.1

Published

DeferredPaymentEscrow ABI for x402 deferred payment scheme

Readme

@perkos/contracts-escrow

TypeScript ABI and types for the DeferredPaymentEscrowUpgradeable smart contract used in the x402 deferred payment scheme.

Installation

npm install @perkos/contracts-escrow

Usage

import {
  DEFERRED_ESCROW_ABI,
  ESCROW_ADDRESSES,
  getEscrowAddress,
  type Voucher,
  type DepositAuthorization,
  type FlushRequest,
  type ThawInfo
} from '@perkos/contracts-escrow';
import { createPublicClient, http } from 'viem';
import { base } from 'viem/chains';

// Create client
const client = createPublicClient({
  chain: base,
  transport: http()
});

// Get escrow address for network
const escrowAddress = getEscrowAddress('base-sepolia');

// Read deposit amount
const depositAmount = await client.readContract({
  address: escrowAddress,
  abi: DEFERRED_ESCROW_ABI,
  functionName: 'getDepositAmount',
  args: [buyerAddress, sellerAddress, assetAddress]
});

// Check if voucher was claimed
const isClaimed = await client.readContract({
  address: escrowAddress,
  abi: DEFERRED_ESCROW_ABI,
  functionName: 'voucherClaimed',
  args: [voucherId, nonce]
});

Contract Functions

Deposit Functions

| Function | Description | |----------|-------------| | deposit(seller, asset, amount) | Deposit tokens for a seller | | depositWithAuthorization(auth, signature) | Deposit with EIP-3009 authorization | | depositWithPermit(seller, asset, amount, deadline, v, r, s) | Deposit with EIP-2612 permit |

Claim Functions

| Function | Description | |----------|-------------| | claimVoucher(voucher, signature) | Claim payment using signed voucher | | claimVoucherBatch(vouchers, signatures) | Batch claim multiple vouchers |

Withdrawal Functions

| Function | Description | |----------|-------------| | thaw(seller, asset, amount) | Initiate withdrawal cooling period | | withdraw(seller, asset) | Complete withdrawal after thaw period | | flush(request, signature) | Emergency flush with seller signature |

View Functions

| Function | Description | |----------|-------------| | getDepositAmount(buyer, seller, asset) | Check deposit balance | | getClaimedAmount(buyer, seller, asset) | Check claimed balance | | getAvailableBalance(buyer, seller, asset) | Check available (unclaimed) balance | | authorizationUsed(address, nonce) | Check if authorization nonce was used | | voucherClaimed(voucherId, nonce) | Check if voucher was already claimed |

Types

Voucher

interface Voucher {
  id: `0x${string}`;
  buyer: `0x${string}`;
  seller: `0x${string}`;
  valueAggregate: bigint;
  asset: `0x${string}`;
  timestamp: bigint;
  nonce: bigint;
  escrow: `0x${string}`;
  chainId: bigint;
}

DepositAuthorization

interface DepositAuthorization {
  buyer: `0x${string}`;
  seller: `0x${string}`;
  asset: `0x${string}`;
  amount: bigint;
  validAfter: bigint;
  validBefore: bigint;
  nonce: `0x${string}`;
}

FlushRequest

interface FlushRequest {
  buyer: `0x${string}`;
  seller: `0x${string}`;
  asset: `0x${string}`;
  validAfter: bigint;
  validBefore: bigint;
  nonce: `0x${string}`;
}

Events

  • Deposited(buyer, seller, asset, amount)
  • VoucherClaimed(voucherId, nonce, buyer, seller, amount)
  • ThawStarted(buyer, seller, asset, amount)
  • Withdrawn(buyer, seller, asset, amount)

Contract Architecture

The contract uses the UUPS (Universal Upgradeable Proxy Standard) pattern from OpenZeppelin, allowing for bug fixes and feature additions without redeployment.

Related Packages

License

MIT