settleRail
settleRail(
client,options):Promise<`0x${string}`>
Defined in: packages/synapse-core/src/pay/settle-rail.ts:73
Settle a payment rail up to a specific epoch
Settles accumulated payments for a rail, transferring funds from the payer to the payee. The settlement can be done up to a specific epoch (must be <= current epoch). If untilEpoch is not provided, it will settle up to the current epoch.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client | Client<Transport, Chain, Account> | The viem client with account to use for the transaction. |
options | OptionsType | settleRail.OptionsType |
Returns
Section titled “Returns”Promise<`0x${string}`>
The transaction hash
Throws
Section titled “Throws”Errors settleRail.ErrorType
Example
Section titled “Example”import { settleRail } from '@filoz/synapse-core/pay'import { createWalletClient, http } 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(),})
// Settle rail up to current epochconst hash = await settleRail(client, { railId: 1n,})
// Settle rail up to a specific epochconst hash2 = await settleRail(client, { railId: 1n, untilEpoch: 1000n,})
console.log(hash)