Skip to content

depositWithPermitSync

depositWithPermitSync(client, options): Promise<OutputType>

Defined in: packages/synapse-core/src/pay/deposit-with-permit.ts:179

Deposit funds using an ERC-2612 permit and wait for confirmation

Signs an EIP-712 permit and deposits, then waits for the transaction to be confirmed. Returns the receipt with the DepositRecorded event.

ParameterTypeDescription
clientClient<Transport, Chain, Account>The viem client with account to use for the transaction.
options{ address?: `0x${string}`; amount: bigint; deadline?: bigint; onHash?: (hash) => void; spender?: `0x${string}`; token?: `0x${string}`; }depositWithPermitSync.OptionsType
options.address?`0x${string}`The depositor address. If not provided, the client account address will be used.
options.amountbigintThe amount to deposit (in token base units). Must be greater than 0.
options.deadline?bigintThe permit deadline as a Unix timestamp (seconds). If not provided, defaults to now + 1 hour.
options.onHash?(hash) => voidCallback function called with the transaction hash before waiting for the receipt.
options.spender?`0x${string}`The spender address for the permit. If not provided, the payments contract address will be used.
options.token?`0x${string}`The address of the ERC20 token. If not provided, the USDFC token address will be used.

Promise<OutputType>

The transaction receipt and extracted event depositWithPermitSync.OutputType

Errors depositWithPermitSync.ErrorType

import { depositWithPermitSync } from '@filoz/synapse-core/pay'
import { createWalletClient, http, parseUnits } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { calibration } from '@filoz/synapse-core/chains'
const account = privateKeyToAccount('0x...')
const client = createWalletClient({
account,
chain: calibration,
transport: http(),
})
const { receipt, event } = await depositWithPermitSync(client, {
amount: parseUnits('100', 18),
onHash: (hash) => console.log('Transaction sent:', hash),
})
console.log('Deposited amount:', event.args.amount)