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

paymaster-sdk

v0.1.0

Published

SDK for interacting with UniswapPaymaster - pay for transactions with any token via Uniswap V4

Readme

UniswapPaymaster SDK

A lightweight SDK for interacting with the UniswapPaymaster contract. Pay for transactions with any token using Uniswap V4 liquidity pools.

Features

  • 🔐 Permit2 Integration - Gasless token approvals using Permit2
  • 🦄 Uniswap V4 - Leverage any [ETH, Token] pool as a paymaster
  • 🌐 Decentralized - No centralized service required
  • Simple - Built on viem for easy integration

Installation

npm install @uniswap-paymaster/sdk viem

Quick Start

import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { sepolia } from 'viem/chains'
import { buildPaymasterData } from '@uniswap-paymaster/sdk'

// Setup
const client = createPublicClient({
  chain: sepolia,
  transport: http(),
})

const account = privateKeyToAccount('0x...')

// Build paymaster data
const paymasterData = await buildPaymasterData(client, account, {
  poolKey: {
    currency0: '0x0000000000000000000000000000000000000000', // ETH
    currency1: '0x...', // Your token address
    fee: 3000,
    tickSpacing: 60,
    hooks: '0x0000000000000000000000000000000000000000',
  },
  token: '0x...', // Token you're paying with
  maxTokenAmount: 1000000n, // Max tokens willing to spend
  paymasterAddress: '0x...', // UniswapPaymaster address
  permit2Address: '0x000000000022D473030F116dDEE9F6B43aC78BA3',
  userAddress: account.address,
})

// Use with viem's account abstraction
// (paymasterData goes into your UserOperation)

API Reference

buildPaymasterData

Builds complete paymaster data including Permit2 signature.

async function buildPaymasterData(
  client: Client,
  account: LocalAccount,
  params: {
    poolKey: PoolKey
    token: Address
    maxTokenAmount: bigint
    paymasterAddress: Address
    permit2Address: Address
    userAddress: Address
    deadline?: bigint // Optional
    nonce?: bigint // Optional, auto-fetched
  }
): Promise<Hex>

signPermit2

Signs a Permit2 permit using EIP-712.

async function signPermit2(params: {
  account: LocalAccount
  chainId: number
  permit2Address: Address
  permit: Permit2Permit
}): Promise<Hex>

getPermit2Nonce

Fetches the current Permit2 nonce for a user.

async function getPermit2Nonce(
  client: Client,
  params: {
    permit2Address: Address
    owner: Address
    token: Address
    spender: Address
  }
): Promise<bigint>

How It Works

  1. User wants to pay with tokens instead of ETH
  2. SDK builds Permit2 permit - allows paymaster to spend tokens
  3. User signs permit - no on-chain transaction needed
  4. Paymaster swaps tokens for ETH via Uniswap V4 during validation
  5. Transaction executes - paid for by the paymaster

Types

type PoolKey = {
  currency0: Address // Must be address(0) for ETH
  currency1: Address // Your token address
  fee: number
  tickSpacing: number
  hooks: Address
}

type Permit2Permit = {
  details: {
    token: Address
    amount: bigint
    expiration: bigint
    nonce: bigint
  }
  spender: Address
  sigDeadline: bigint
}

Examples

See the examples directory for complete integration examples.

License

MIT