> For the complete documentation index, see [llms.txt](https://docs.blockz.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.blockz.fi/on-chain-helpers/approve-for-permit2.md).

# Approve for Permit2

Before a Permit2 signature can be used, the Permit2 contract must be approved to transfer the user's tokens.

This is done by calling the `approve` method on the token contract and granting the Permit2 contract permission to spend the token.

```solidity
function approve(
      address spender, // address of permit2 contract
      uint256 value    // uint256.max value to grant infinite approve
) public virtual returns (bool)
```

Approval is performed **once per token** and does not need to be repeated for future swaps unless the allowance is revoked.

**Example:**

{% code title="approvePermit2.ts" %}

```typescript
import { ethers } from "ethers";

const ERC20_ABI = [
  "function approve(address spender, uint256 value) external returns (bool)"
];

async function approvePermit2(
  tokenAddress: string,
  permit2Address: string,
  signer: ethers.Signer
) {
  const token = new ethers.Contract(tokenAddress, ERC20_ABI, signer);
  const tx = await token.approve(permit2Address, ethers.MaxUint256);
  await tx.wait();
}
```

{% endcode %}
