MCPcopy Create free account
hub / github.com/circlefin/arc-node / signPermit

Function signPermit

tests/helpers/FiatToken.ts:211–261  ·  view source on GitHub ↗
({
  client,
  wallet,
  permitAmount,
  spenderAddress,
  nonce,
  deadline = maxUint256,
  tokenAddress = USDC.address,
}: {
  client: PublicClient
  wallet: WalletClient
  permitAmount: bigint
  deadline?: bigint
  spenderAddress: Address
  nonce?: bigint
  tokenAddress?: Address
})

Source from the content-addressed store, hash-verified

209}
210
211export async function signPermit({
212 client,
213 wallet,
214 permitAmount,
215 spenderAddress,
216 nonce,
217 deadline = maxUint256,
218 tokenAddress = USDC.address,
219}: {
220 client: PublicClient
221 wallet: WalletClient
222 permitAmount: bigint
223 deadline?: bigint
224 spenderAddress: Address
225 nonce?: bigint
226 tokenAddress?: Address
227}) {
228 const token = getContract({
229 client,
230 address: tokenAddress,
231 abi: [...eip2612Abi, ...erc20Abi],
232 })
233
234 const signature = await wallet.signTypedData({
235 types: {
236 Permit: [
237 { name: 'owner', type: 'address' },
238 { name: 'spender', type: 'address' },
239 { name: 'value', type: 'uint256' },
240 { name: 'nonce', type: 'uint256' },
241 { name: 'deadline', type: 'uint256' },
242 ],
243 },
244 primaryType: 'Permit',
245 domain: {
246 chainId: client.chain?.id,
247 name: await token.read.name(),
248 verifyingContract: token.address,
249 version: await token.read.version(),
250 },
251 message: {
252 owner: wallet.account.address,
253 spender: spenderAddress,
254 value: permitAmount,
255 nonce: nonce ?? (await token.read.nonces([wallet.account.address])),
256 deadline,
257 },
258 })
259
260 return signature
261}

Callers 1

Calls 2

versionMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected