Skip to content

settleRail

settleRail(client, options): Promise<`0x${string}`>

Defined in: packages/synapse-core/src/pay/settle-rail.ts:75

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.

Parameter Type Description
client Client<Transport, Chain, Account> The viem client with account to use for the transaction.
options OptionsType settleRail.OptionsType

Promise<`0x${string}`>

The transaction hash

Errors settleRail.ErrorType

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 epoch
const hash = await settleRail(client, {
  railId: 1n,
})

// Settle rail up to a specific epoch
const hash2 = await settleRail(client, {
  railId: 1n,
  untilEpoch: 1000n,
})

console.log(hash)