Skip to main content

contracts/handlers/erc20-permit-handler

Classes

ERC20PermitHandler

Defined in: lib/contracts/handlers/erc20-permit-handler.ts:24

Handler for performing operations for and with ERC20Permit tokens.

Constructors

Constructor

new ERC20PermitHandler(chain, walletClient, publicClient): ERC20PermitHandler

Defined in: lib/contracts/handlers/erc20-permit-handler.ts:37

Create the handler for processing tokens.

Parameters
ParameterTypeDescription
chainChainChain to use for the client.
walletClient{ }The wallet client to use for wallet interactions.
publicClient{ }The public client to use for public interactions.
Returns

ERC20PermitHandler

Methods

approve()

approve(ownerAddress, spenderAddress, value): Promise<`0x${string}`>

Defined in: lib/contracts/handlers/erc20-permit-handler.ts:170

Approve transaction for the spender to spend the owner's tokens.

Parameters
ParameterTypeDescription
ownerAddress`0x${string}`Address of the caller of the transaction.
spenderAddress`0x${string}`Address of the spender.
valuebigintValue to approve for the spender.
Returns

Promise<`0x${string}`>

Hash of the transaction.

getContract()

getContract(): object

Defined in: lib/contracts/handlers/erc20-permit-handler.ts:63

Get the contract. This is a method because the typings are complex and lost when trying to make it a member.

Returns

object

The viem contract.

getPermitData()

getPermitData(ownerAddress, spenderAddress, value): Promise<PermitData>

Defined in: lib/contracts/handlers/erc20-permit-handler.ts:147

Get the permit data for the given owner, spender and value.

Parameters
ParameterTypeDescription
ownerAddress`0x${string}`Address of the token owner.
spenderAddress`0x${string}`Address of the spender who needs the permit.
valuebigintValue/amount to be permitted.
Returns

Promise<PermitData>

Permit data in the form { r, s, v, deadline, amount }.

getPermitSignature()

getPermitSignature(ownerAddress, spenderAddress, value): Promise<{ deadline: bigint; } | { deadline: bigint; }>

Defined in: lib/contracts/handlers/erc20-permit-handler.ts:94

Process and get permit signature for the given token to perform transactions without calling approve().

Parameters
ParameterTypeDescription
ownerAddress`0x${string}`Address of the token owner.
spenderAddress`0x${string}`Address of the spender who needs the permit.
valuebigintValue of the transaction.
Returns

Promise<{ deadline: bigint; } | { deadline: bigint; }>

Permit signature in the form { r, s, v?, yParity }.

nonces()

nonces(account): Promise<bigint>

Defined in: lib/contracts/handlers/erc20-permit-handler.ts:81

Get the nonces for the given account.

Parameters
ParameterTypeDescription
account`0x${string}`Address of the account.
Returns

Promise<bigint>

The nonces.

withToken()

withToken(token): ERC20PermitHandler

Defined in: lib/contracts/handlers/erc20-permit-handler.ts:52

Set the token to use for executing transactions on the contract.

Parameters
ParameterTypeDescription
tokenAnyTokenToken to use for the handler.
Returns

ERC20PermitHandler

The handler.