@kodex-data/permit
v0.0.1-rc.6
Published
ERC20 permit helper forked from uniswap.
Downloads
17
Readme
@kodex-data/permit
@kodex-data/permit
is a helper package that provides ERC20 permit functionality. This package is a fork of the Uniswap protocol's package, and it provides a simple way to generate permit signatures for ERC20 tokens. By using this package, you can easily enable users to approve token transfers without the need for multiple transactions.
Installation
You can install @kodex-data/permit
using yarn
or npm
. Here's how you can do it:
yarn add @kodex-data/permit
# or
npm install @kodex-data/permit
Usage
Once you have installed the package, you can import the getPermitSignature
function from the package to generate a permit signature. Here's how you can use it:
import { getPermitSignature } from '@kodex-data/permit'
// generate permit signature
const permitSignature = await getPermitSignature(
provider, // the Ethereum provider
tokenAddress, // the address of the ERC20 token
ownerAddress, // the address of the token owner
spenderAddress, // the address of the token spender
value, // the amount of tokens that can be spent
deadline, // the deadline for the permit in seconds since the Unix epoch
nonce // a unique value that prevents replay attacks
)
This function returns a Promise that resolves to the permit signature as a string.