一键导入
permit2-allowance-transfer
Uses AllowanceTransfer for persistent token approvals. Use when user grants recurring spend authority to the protocol.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Uses AllowanceTransfer for persistent token approvals. Use when user grants recurring spend authority to the protocol.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
AI-powered crypto trading agent, wallet API, and LLM gateway via natural language. Use when the user wants to trade crypto, trade tokenized stocks and ETFs (spot or leveraged), check portfolio balances (with PnL and NFTs), view token prices, search tokens, transfer crypto, manage NFTs, use leverage (Hyperliquid or Avantis), bet on Polymarket, deploy tokens, set up automated trading, sign and submit raw transactions, call or deploy x402 paid API endpoints, browse the web, or access LLM models through the Bankr LLM gateway funded by your Bankr wallet. Supports Base, Ethereum, Polygon, Solana, Unichain, World Chain, Arbitrum, BNB Chain, and Robinhood Chain.
Live pay-per-call data for crypto and DeFi protocol risk, funding rates, open interest, liquidations, stablecoin health, macro, equities, and on-chain intelligence — settled per query in USDC on Base via x402, no signup or API key.
This skill should be used when the user asks about "create3", "deploy", "diamond factory", "package", "deterministic deployment", "cross-chain", "DiamondPackageCallBackFactory", "FactoryService", or needs guidance on deploying Diamond proxies and facets using Crane's factory system.
This skill should be used when the user asks about "testbase", "behavior library", "invariant test", "handler", "fuzz test", "test pattern", "Behavior_", "TestBase_", "mock", "vm.mockCall", "unit test", "write a test", "CraneTest", or needs guidance on Crane's testing infrastructure for writing comprehensive smart contract tests. Prefer production code over mocks.
Foundry cheatcodes, assertions, and forge test CLI. Use for vm.prank, expectRevert, verbosity, and general Foundry mechanics. For Crane/IndexedEx protocol and Diamond tests, prefer crane-testing and production-first deploy paths over mocks.
This skill should be used when the user asks about "facet", "target", "repo", "diamond pattern", "storage slot", "guard function", "DFPkg", "AwareRepo", "Service pattern", "Modifiers", "ERC2535", or needs guidance on Crane's core architectural patterns for building modular, upgradeable smart contracts.
| name | permit2-allowance-transfer |
| description | Uses AllowanceTransfer for persistent token approvals. Use when user grants recurring spend authority to the protocol. |
Two-step approval pattern: (1) ERC20→Permit2, (2) Permit2→spender. Used when you want persistent allowance without per-tx signatures.
This is what the frontend currently uses for swaps:
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)
]
})
// 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]
})
| 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 |
See permit2-allowance-flow skill for complete implementation with reset-to-zero pattern.