{"id":19924150,"url":"https://github.com/vacekj/wagmi-permit","last_synced_at":"2025-05-03T07:31:17.340Z","repository":{"id":210556772,"uuid":"686350512","full_name":"vacekj/wagmi-permit","owner":"vacekj","description":"All you need to sign ERC2612 and DAI permits with wagmi and viem","archived":false,"fork":false,"pushed_at":"2024-11-17T12:31:53.000Z","size":215,"stargazers_count":34,"open_issues_count":3,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T13:11:12.484Z","etag":null,"topics":["ethereum","permit","viem","wagmi"],"latest_commit_sha":null,"homepage":"https://vacekj.github.io/wagmi-permit","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vacekj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-02T13:52:11.000Z","updated_at":"2025-04-02T18:19:33.000Z","dependencies_parsed_at":"2023-12-03T17:22:32.969Z","dependency_job_id":"6b1bcddd-48f2-47df-b5da-08317ffd0f02","html_url":"https://github.com/vacekj/wagmi-permit","commit_stats":null,"previous_names":["vacekj/wagmi-permit"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vacekj%2Fwagmi-permit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vacekj%2Fwagmi-permit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vacekj%2Fwagmi-permit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vacekj%2Fwagmi-permit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vacekj","download_url":"https://codeload.github.com/vacekj/wagmi-permit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252156886,"owners_count":21703369,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ethereum","permit","viem","wagmi"],"created_at":"2024-11-12T22:16:31.985Z","updated_at":"2025-05-03T07:31:16.778Z","avatar_url":"https://github.com/vacekj.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wagmi Permit\n\n![npm](https://img.shields.io/npm/v/wagmi-permit)\n![npm](https://img.shields.io/npm/dm/wagmi-permit)\n\nAll you need to sign ERC-2612/DAI permits with viem and wagmi.\n\n- [Wagmi-Permit](#wagmi-permit)\n    * [Features](#features)\n    * [Installation](#installation)\n    * [Usage](#usage)\n        + [Hook](#hook)\n        + [Hook with overrides](#hook-with-overrides)\n        + [Dai hook](#dai-hook)\n        + [Actions](#actions)\n- [Example app](#example-app)\n- [Permit information for common tokens](#permit-information-for-common-tokens)\n- [Credits](#credits)\n\n\n## Features\n- A set of functions and wagmi hooks to sign Permits\n- Supports both ERC-2612 Permit and Dai non-standard permit\n- Automatically manages nonce, version and token name - just pass in the contract address\n- Handles USDC on Polygon PoS edge-case\n\n## Installation\n\n```bash\nnpm i wagmi-permit\n```\n```bash\npnpm add wagmi-permit\n```\n```bash\nbun i wagmi-permit\n```\n```bash\nyarn add wagmi-permit\n```\n\n## Usage\n\nThe auto-generated API docs [can be found here](https://vacekj.github.io/wagmi-permit)\n\n### Hook\n\n```typescript jsx\nimport { usePermit } from \"wagmi-permit\";\n\nfunction PermitExample() {\n  const { data: walletClient } = useWalletClient();\n  /* No need to specify name, nonce and permit version, the hook takes care of all that automatically */\n  const { signPermit, signature } = usePermit({\n    walletClient,\n    ownerAddress: walletClient?.account.address,\n    chainId: 1,\n    spenderAddress: \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\", // vitalik.eth\n    contractAddress: \"0xa2327a938febf5fec13bacfb16ae10ecbc4cbdcf\", // usdc on mainnet\n    value: parseEther(\"10\"),\n    deadline: BigInt(Math.floor(Date.now() / 1000) + 100_000),\n  });\n\n  return (\n    \u003c\u003e\n      \u003cpre\u003e{JSON.stringify(signature, null, 2)}\u003c/pre\u003e\n      \u003cbutton\n        onClick={async () =\u003e {\n          /* Permit signature is returned both from the action and from the hook */\n          const permitSignature = await signPermit?.();\n          console.log(permitSignature);\n        }}\n      \u003e\n        Sign Permit\n      \u003c/button\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n### Hook with overrides\n\nYou can override the data passed to the permit signature in the hook...\n\n```typescript jsx\nconst { signPermit, signature } = usePermit({\n  walletClient,\n  ownerAddress: walletClient?.account.address,\n  chainId: 1,\n  spenderAddress: \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\", // vitalik.eth\n  contractAddress: \"0xa2327a938febf5fec13bacfb16ae10ecbc4cbdcf\", // usdc on mainnet\n  value: parseEther(\"10\"),\n  deadline: BigInt(Math.floor(Date.now() / 1000) + 100_000),\n  /** Overrides */\n  nonce: 2n,\n  erc20Name: \"Overriden Token Name\",\n  version: \"2\",\n});\n```\n\nor directly in the function\n\n```typescript jsx\n\u003cbutton\n  onClick={async () =\u003e {\n    /* Permit signature is returned both from the action and from the hook */\n    const permitSignature = await signPermit?.({\n      nonce: 2n,\n      erc20Name: \"Overriden Token Name\",\n      version: \"2\",\n    });\n    console.log(permitSignature);\n  }}\n\u003e\n  Sign Permit\n\u003c/button\u003e\n```\n\n### Dai hook\n\nSign Dai permits with the signPermitDai function returned from the hook\n\n```typescript jsx\nimport { usePermit } from \"wagmi-permit\";\n\nfunction DaiPermitExample() {\n  const { data: walletClient } = useWalletClient();\n  const { signPermitDai, signature } = usePermit({\n    walletClient,\n    ownerAddress: walletClient?.account.address,\n    chainId: 1,\n    spenderAddress: \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\", // vitalik.eth\n    contractAddress: \"0x6b175474e89094c44da98b954eedeac495271d0f\", // dai on mainnet\n    value: parseEther(\"10\"),\n    deadline: BigInt(Math.floor(Date.now() / 1000) + 100_000),\n  });\n\n  return (\n    \u003c\u003e\n      \u003cpre\u003e{JSON.stringify(signature, null, 2)}\u003c/pre\u003e\n      \u003cbutton\n        onClick={async () =\u003e {\n          /* Permit signature is returned both from the action and from the hook */\n          const permitSignature = await signPermitDai?.();\n          console.log(permitSignature);\n        }}\n      \u003e\n        Sign Permit\n      \u003c/button\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n### Actions\n\nYou can also use just the permit signing functions, for both standard tokens and Dai\n\n```typescript\nimport {signPermit} from \"wagmi-permit\";\nimport {WalletClient} from \"wagmi\";\n\nasync function signPermitForUSDC(walletClient: WalletClient) {\n  const sig = await signPermit(walletClient, {\n    spenderAddress: \"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266\",\n    ownerAddress: \"0x70997970C51812dc3A010C7d01b50e0d17dc79C8\",\n    contractAddress: \"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\",\n    erc20Name: \"USD Coin\",\n    version: \"2\",\n    deadline: BigInt(Math.floor(Date.now() / 1000) + 100_000),\n    nonce: 0n,\n    chainId: 1,\n    value: 1_000_000_000n,\n  });\n\n  console.log(sig);\n}\n```\n\n# Example app\n\nPlay with an example of signing a USDC permit on Optimism Mainnet in the example app under `example-app`.\n\n```bash\ngit clone https://github.com/vacekj/wagmi-permit\ncd wagmi-permit\ncd example-app\nnpm i\nnpm run dev\n```\n\n# Permit information for common tokens\n\nInformation on various tokens, their supported permit type, version and methods can be found in [PERMIT.md](PERMIT.md)\n\n# Credits\n\nThank you to [Ana](https://twitter.com/AnaArsonist), [dcbuilder](https://twitter.com/dcbuild3r) and [sofia](https://twitter.com/al3thi0meter) for feedback.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvacekj%2Fwagmi-permit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvacekj%2Fwagmi-permit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvacekj%2Fwagmi-permit/lists"}