Skip to content

SamuraiT/ethers-js-permit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ethers-js-permit

Ethers-js-permit is a support library for ethers-js that allows for easy generation of signatures for ERC20Permit.

Install

yarn add ethers-js-permit

USAGE

  import { signPermitSigature } from 'ethers-js-permit'

  const wallet = Wallet.createRandom()
  const nonce = await erc20Permit.nonces(wallet.address)
  const name = await erc20Permit.name()
  const permitConfig = {
    nonce,
    name,
    chainId: 1, // -> this should be 1 for ethereum.
    version: '1'
  }
  const deadline = 60 * 60 * 24

  const result = await signPermitSigature(
    wallet,
    wallet.address,
    erc20Permit.address,
    targetContract,
    BigNumber.from('100'),
    deadline,
    permitConfig
  )

  await targetContract.removeLiquidity( // contract call with permit
    ...,
    deadline,
    false,
    result.v,
    result.r,
    result.s
  )