Skip to content
Back to skills

Permit2 Allowance Transfer

ASecurity

Uses AllowanceTransfer for persistent token approvals. Use when user grants recurring spend authority to the protocol.

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 10, 2026
developmenttypescriptfrontendsecurity

Works with

  • cli

Security analysis

A100/100

Scanned September 10, 2026

npx -y skills add cyotee/indexedex --skill permit2-allowance-transfer --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Permit2 Allowance Transfer?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Permit2 Allowance Transfer
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/cyotee-permit2-allowance-transfer/badge)](https://www.skillsdirectory.com/skills/cyotee-permit2-allowance-transfer)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: permit2-allowance-transfer
description: Uses AllowanceTransfer for persistent token approvals. Use when user grants recurring spend authority to the protocol.
---

# Permit2 Allowance Transfer

Two-step approval pattern: (1) ERC20→Permit2, (2) Permit2→spender. Used when you want persistent allowance without per-tx signatures.

## Current Implementation Pattern

This is what the frontend currently uses for swaps:

```typescript
import { useWriteContract, useReadContract, useAccount } from 'wagmi'
import { erc20Abi } from 'viem'

// Step 1: ERC20 → Permit2 (one-time or recurring)
const tokenApproveWrite = useWriteContract()
await tokenApproveWrite.writeContractAsync({
  address: tokenAddress,
  abi: erc20Abi,
  functionName: 'approve',
  args: [PERMIT2_ADDRESS, BigInt(amount)]
})

// Step 2: Permit2 → Router (persistent)
const permit2Write = useWriteContract()
await permit2Write.writeContractAsync({
  address: PERMIT2_ADDRESS,
  abi: permit2ApproveAbi,
  functionName: 'approve',
  args: [
    tokenAddress,
    routerAddress,
    BigInt(amount),
    BigInt(expiration)
  ]
})
```

## Reading Allowances

```typescript
// ERC20 allowance (token → Permit2)
const tokenAllowance = await publicClient.readContract({
  address: tokenAddress,
  abi: erc20Abi,
  functionName: 'allowance',
  args: [owner, PERMIT2_ADDRESS]
})

// Permit2 allowance (Permit2 → router)
const permit2Allowance = await publicClient.readContract({
  address: PERMIT2_ADDRESS,
  abi: [{
    inputs: [
      { name: 'owner', type: 'address' },
      { name: 'token', type: 'address' },
      { name: 'spender', type: 'address' }
    ],
    name: 'allowance',
    outputs: [
      { name: 'amount', type: 'uint160' },
      { name: 'expiration', type: 'uint48' },
      { name: 'nonce', type: 'uint48' }
    ],
    stateMutability: 'view',
    type: 'function'
  }],
  functionName: 'allowance',
  args: [owner, tokenAddress, routerAddress]
})
```

## When to Use This vs Signature Transfer

| Scenario | Use |
|----------|-----|
| User doing frequent trades | AllowanceTransfer |
| One-time signature-based swap | SignatureTransfer |
| Gas optimization for repeated ops | AllowanceTransfer |
| Max security / no pre-approval | SignatureTransfer |

## Full Approval Flow

See `permit2-allowance-flow` skill for complete implementation with reset-to-zero pattern.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.