Skip to content

getRailsForPayerAndToken

getRailsForPayerAndToken(client, options): Promise<OutputType>

Defined in: packages/synapse-core/src/pay/get-rails-for-payer-and-token.ts:97

Get rails for a payer and token with pagination

Returns paginated list of rails where the specified address is the payer for the given token. Use pagination (offset and limit) to handle large result sets efficiently.

ParameterTypeDescription
clientClient<Transport, Chain>The client to use to get the rails.
optionsOptionsTypegetRailsForPayerAndToken.OptionsType

Promise<OutputType>

Paginated rail results getRailsForPayerAndToken.OutputType

Errors getRailsForPayerAndToken.ErrorType

import { getRailsForPayerAndToken } from '@filoz/synapse-core/pay'
import { createPublicClient, http } from 'viem'
import { calibration } from '@filoz/synapse-core/chains'
const client = createPublicClient({
chain: calibration,
transport: http(),
})
// Get first 10 rails
const result = await getRailsForPayerAndToken(client, {
payer: '0x1234567890123456789012345678901234567890',
offset: 0n,
limit: 10n,
})
console.log(`Found ${result.total} total rails`)
console.log(`Returned ${result.results.length} rails`)
for (const rail of result.results) {
console.log(`Rail ${rail.railId}: ${rail.isTerminated ? 'Terminated' : 'Active'}`)
}