withdraw
withdraw(
client,options):Promise<`0x${string}`>
Defined in: packages/synapse-core/src/pay/withdraw.ts:69
Withdraw funds from the Filecoin Pay contract
Withdraws ERC20 tokens from the payments contract to the caller’s address. The withdrawal amount must not exceed available funds (deposited funds minus locked funds).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client | Client<Transport, Chain, Account> | The viem client with account to use for the transaction. |
options | OptionsType | withdraw.OptionsType |
Returns
Section titled “Returns”Promise<`0x${string}`>
The transaction hash
Throws
Section titled “Throws”Errors withdraw.ErrorType
Example
Section titled “Example”import { withdraw } 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(),})
// Withdraw 100 USDFC to own accountconst hash = await withdraw(client, { amount: parseUnits('100', 18),})
console.log(hash)