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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client | Client<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.amount | bigint | The amount to deposit (in token base units). Must be greater than 0. |
options.deadline? | bigint | The permit deadline as a Unix timestamp (seconds). If not provided, defaults to now + 1 hour. |
options.onHash? | (hash) => void | Callback 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. |
Returns
Section titled “Returns”The transaction receipt and extracted event depositWithPermitSync.OutputType
Throws
Section titled “Throws”Errors depositWithPermitSync.ErrorType
Example
Section titled “Example”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)