# settleRailSync

> **settleRailSync**(`client`, `options`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`OutputType`](/reference/filoz/synapse-core/pay/namespaces/settlerailsync/type-aliases/outputtype/)\>

Defined in: [packages/synapse-core/src/pay/settle-rail.ts:150](https://github.com/FilOzone/synapse-sdk/blob/6cf8b3ed2dd3ae76ed05cb86995d711a08a298a6/packages/synapse-core/src/pay/settle-rail.ts#L150)

Settle a payment rail up to a specific epoch and wait for confirmation

Settles accumulated payments for a rail and waits for the transaction to be confirmed.
Returns the receipt with the RailSettled event.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `client` | `Client`\<`Transport`, `Chain`, `Account`\> | The viem client with account to use for the transaction. |
| `options` | [`OptionsType`](/reference/filoz/synapse-core/pay/namespaces/settlerailsync/type-aliases/optionstype/) | [settleRailSync.OptionsType](/reference/filoz/synapse-core/pay/namespaces/settlerailsync/type-aliases/optionstype/) |

## Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`OutputType`](/reference/filoz/synapse-core/pay/namespaces/settlerailsync/type-aliases/outputtype/)\>

The transaction receipt and extracted event [settleRailSync.OutputType](/reference/filoz/synapse-core/pay/namespaces/settlerailsync/type-aliases/outputtype/)

## Throws

Errors [settleRailSync.ErrorType](/reference/filoz/synapse-core/pay/namespaces/settlerailsync/type-aliases/errortype/)

## Example

```ts
import { settleRailSync } 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(),
})

const { receipt, event } = await settleRailSync(client, {
  railId: 1n,
  onHash: (hash) => console.log('Transaction sent:', hash),
})

console.log('Total settled amount:', event.args.totalSettledAmount)
console.log('Settled up to epoch:', event.args.settledUpTo)
```