Skip to content

PaymentsService

Defined in: packages/synapse-sdk/src/payments/service.ts:45

PaymentsService - Filecoin Pay client for managing deposits, approvals, and payment rails

new PaymentsService(options): PaymentsService

Defined in: packages/synapse-sdk/src/payments/service.ts:55

Create a new PaymentsService instance

ParameterTypeDescription
options{ client: Client<Transport, Chain, Account>; }Options for the PaymentsService
options.clientClient<Transport, Chain, Account>Viem wallet client

PaymentsService

A new PaymentsService instance

accountInfo(options?): Promise<OutputType>

Defined in: packages/synapse-sdk/src/payments/service.ts:111

Get detailed account information from the payments contract

ParameterTypeDescription
options{ token?: string; }Options for the account info
options.token?stringThe token to get account info for (defaults to USDFC)

Promise<OutputType>

Account information Pay.accounts.OutputType

Errors Pay.accounts.ErrorType


allowance(options): Promise<bigint>

Defined in: packages/synapse-sdk/src/payments/service.ts:191

Check the current ERC20 token allowance for a spender

ParameterTypeDescription
options{ spender: `0x${string}`; token?: string; }Options for the allowance check
options.spender`0x${string}`The address to check allowance for
options.token?stringThe token to check allowance for (defaults to USDFC)

Promise<bigint>

The current allowance amount as bigint

Errors ERC20.balance.ErrorType


approve(options): Promise<`0x${string}`>

Defined in: packages/synapse-sdk/src/payments/service.ts:226

Approve an ERC20 token spender

ParameterTypeDescription
options{ amount: bigint; spender: `0x${string}`; token?: string; }Options for the approve
options.amountbigintThe amount to approve
options.spender`0x${string}`The address to approve as spender
options.token?stringThe token to approve spending for (defaults to USDFC)

Promise<`0x${string}`>

Transaction response object


approveService(options?): Promise<`0x${string}`>

Defined in: packages/synapse-sdk/src/payments/service.ts:265

Approve a service contract to act as an operator for payment rails This allows the service contract (such as Warm Storage) to create and manage payment rails on behalf of the client

ParameterTypeDescription
options{ lockupAllowance?: bigint; maxLockupPeriod?: bigint; rateAllowance?: bigint; service?: `0x${string}`; token?: string; }Options for the approve service
options.lockupAllowance?bigintMaximum lockup amount the operator can set (defaults to maxUint256)
options.maxLockupPeriod?bigintMaximum lockup period in epochs the operator can set (defaults to 30 days in epochs)
options.rateAllowance?bigintMaximum payment rate per epoch the operator can set (defaults to maxUint256)
options.service?`0x${string}`The service contract address to approve (defaults to Warm Storage contract address)
options.token?stringThe token to approve for (defaults to USDFC)

Promise<`0x${string}`>

Transaction hash Hash

Errors Pay.setOperatorApproval.ErrorType


balance(options?): Promise<bigint>

Defined in: packages/synapse-sdk/src/payments/service.ts:90

Get the balance of the payments contract

ParameterTypeDescription
options{ token?: string; }Options for the balance
options.token?stringThe token to get balance for (defaults to USDFC)

Promise<bigint>

The balance of the payments contract

Errors Pay.accounts.ErrorType


decimals(): number

Defined in: packages/synapse-sdk/src/payments/service.ts:177

number


deposit(options): Promise<`0x${string}`>

Defined in: packages/synapse-sdk/src/payments/service.ts:380

Deposit funds into the payments contract

ParameterTypeDescription
optionsDepositOptionsOptions for the deposit DepositOptions

Promise<`0x${string}`>

Transaction hash Hash

Errors ERC20.balance.ErrorType | ERC20.approve.ErrorType | Pay.deposit.ErrorType


depositWithPermit(options): Promise<`0x${string}`>

Defined in: packages/synapse-sdk/src/payments/service.ts:444

Deposit funds using ERC-2612 permit to approve and deposit in a single transaction This method creates an EIP-712 typed-data signature for the USDFC token’s permit, then calls the Payments contract depositWithPermit to pull funds and credit the account.

ParameterTypeDescription
options{ amount: bigint; deadline?: bigint; token?: string; }Options for the deposit with permit DepositWithPermitOptions
options.amountbigintAmount of USDFC to deposit (in base units)
options.deadline?bigintUnix timestamp (seconds) when the permit expires. Defaults to now + 1 hour.
options.token?stringToken identifier (currently only USDFC is supported)

Promise<`0x${string}`>

Transaction response object Hash

Errors ERC20.balanceForPermit.ErrorType | ERC20.permit.ErrorType | Pay.depositWithPermit.ErrorType


depositWithPermitAndApproveOperator(options): Promise<`0x${string}`>

Defined in: packages/synapse-sdk/src/payments/service.ts:522

Deposit funds using ERC-2612 permit and approve an operator in a single transaction This signs an EIP-712 permit for the USDFC token and calls the Payments contract function depositWithPermitAndApproveOperator which both deposits and sets operator approval.

ParameterTypeDescription
options{ amount: bigint; deadline?: bigint; lockupAllowance?: bigint; maxLockupPeriod?: bigint; operator?: `0x${string}`; rateAllowance?: bigint; token?: string; }Options for the deposit with permit and approve operator
options.amountbigintAmount of USDFC to deposit (in base units)
options.deadline?bigintUnix timestamp (seconds) when the permit expires. Defaults to now + 1 hour.
options.lockupAllowance?bigintMax lockup amount operator can set
options.maxLockupPeriod?bigintMax lockup period in epochs operator can set
options.operator?`0x${string}`Service/operator address to approve
options.rateAllowance?bigintMax payment rate per epoch operator can set
options.token?stringToken identifier (currently only USDFC supported)

Promise<`0x${string}`>

Transaction hash Hash

Errors ERC20.balanceForPermit.ErrorType | ERC20.permit.ErrorType | Pay.depositWithPermitAndApproveOperator.ErrorType


getRail(options): Promise<OutputType>

Defined in: packages/synapse-sdk/src/payments/service.ts:668

Get detailed information about a specific rail

ParameterTypeDescription
options{ railId: bigint; }Options for the get rail
options.railIdbigintThe rail ID to query

Promise<OutputType>

Rail information including all parameters and current state Pay.getRail.OutputType

When the rail does not exist or is inactive


getRailsAsPayee(options?): Promise<RailInfo[]>

Defined in: packages/synapse-sdk/src/payments/service.ts:754

Get all rails where the wallet is the payee

ParameterTypeDescription
options{ token?: string; }Options for the get rails as payee
options.token?stringThe token to filter by (defaults to USDFC)

Promise<RailInfo[]>

Array of rail information []


getRailsAsPayer(options?): Promise<RailInfo[]>

Defined in: packages/synapse-sdk/src/payments/service.ts:727

Get all rails where the wallet is the payer

ParameterTypeDescription
options{ token?: string; }Options for the get rails as payer
options.token?stringThe token to filter by (defaults to USDFC)

Promise<RailInfo[]>

Array of rail information []


getSettlementAmounts(options): Promise<SettlementResult>

Defined in: packages/synapse-sdk/src/payments/service.ts:611

Get the expected settlement amounts for a rail (read-only simulation)

ParameterTypeDescription
options{ railId: bigint; untilEpoch?: bigint; }Options for the get settlement amounts
options.railIdbigintThe rail ID to check
options.untilEpoch?bigintThe epoch to settle up to (must be <= current epoch; defaults to current). Can be used to preview partial settlements to a past epoch.

Promise<SettlementResult>

Settlement result with amounts and details SettlementResult


revokeService(options?): Promise<`0x${string}`>

Defined in: packages/synapse-sdk/src/payments/service.ts:310

Revoke a service contract’s operator approval

ParameterTypeDescription
options{ service?: `0x${string}`; token?: string; }Options for the revoke service
options.service?`0x${string}`The service contract address to revoke (defaults to Warm Storage contract address)
options.token?stringThe token to revoke approval for (defaults to USDFC)

Promise<`0x${string}`>

Transaction hash Hash

Errors Pay.setOperatorApproval.ErrorType


serviceApproval(options?): Promise<OutputType>

Defined in: packages/synapse-sdk/src/payments/service.ts:345

Get the operator approval status and allowances for a service

ParameterTypeDescription
options{ service?: `0x${string}`; token?: string; }Options for the service approval
options.service?`0x${string}`The service contract address to check (defaults to Warm Storage contract address)
options.token?stringThe token to check approval for (defaults to USDFC)

Promise<OutputType>

Approval status and allowances Pay.operatorApprovals.OutputType

Errors Pay.operatorApprovals.ErrorType


settle(options): Promise<`0x${string}`>

Defined in: packages/synapse-sdk/src/payments/service.ts:595

Settle a payment rail up to a specific epoch (sends a transaction)

ParameterTypeDescription
options{ railId: bigint; untilEpoch?: bigint; }Options for the settle
options.railIdbigintThe rail ID to settle
options.untilEpoch?bigintThe epoch to settle up to (must be <= current epoch; defaults to current). Can be used for partial settlements to a past epoch.

Promise<`0x${string}`>

Transaction hash Hash

Errors Pay.settleRail.ErrorType


settleAuto(options): Promise<`0x${string}`>

Defined in: packages/synapse-sdk/src/payments/service.ts:707

Automatically settle a rail, detecting whether it’s terminated or active This method checks the rail status and calls the appropriate settlement method:

  • For terminated rails: calls settleTerminatedRail()
  • For active rails: calls settle() with optional untilEpoch
ParameterTypeDescription
options{ railId: bigint; untilEpoch?: bigint; }Options for the settle auto
options.railIdbigintThe rail ID to settle
options.untilEpoch?bigintThe epoch to settle up to (must be <= current epoch for active rails; ignored for terminated rails)

Promise<`0x${string}`>

Transaction response object Hash

Error if rail doesn’t exist (contract reverts with RailInactiveOrSettled) or other settlement errors

// Automatically detect and settle appropriately
const hash = await synapse.payments.settleAuto({ railId })
// For active rails, can specify epoch
const hash = await synapse.payments.settleAuto({ railId, untilEpoch: specificEpoch })

settleTerminatedRail(options): Promise<`0x${string}`>

Defined in: packages/synapse-sdk/src/payments/service.ts:657

Emergency settlement for terminated rails only - bypasses service contract validation This ensures payment even if the validator contract is buggy or unresponsive (pays in full) Can only be called by the client after the max settlement epoch has passed

ParameterTypeDescription
options{ railId: bigint; }Options for the settle terminated rail
options.railIdbigintThe rail ID to settle

Promise<`0x${string}`>

Transaction hash Hash

Errors Pay.settleTerminatedRailWithoutValidation.ErrorType


walletBalance(options?): Promise<bigint>

Defined in: packages/synapse-sdk/src/payments/service.ts:133

Get the balance of the wallet

ParameterTypeDescription
options{ token?: string; }Options for the wallet balance
options.token?stringThe token to get wallet balance for (defaults to FIL)

Promise<bigint>

The balance of the wallet

Errors getBalance.ErrorType


withdraw(options): Promise<`0x${string}`>

Defined in: packages/synapse-sdk/src/payments/service.ts:574

Withdraw funds from the payments contract

ParameterTypeDescription
options{ amount: bigint; token?: string; }Options for the withdraw
options.amountbigintThe amount to withdraw
options.token?stringThe token to withdraw (defaults to USDFC)

Promise<`0x${string}`>

Transaction hash Hash

Errors Pay.withdraw.ErrorType


static create(options): PaymentsService

Defined in: packages/synapse-sdk/src/payments/service.ts:68

Create a new PaymentsService with pre-configured client

ParameterTypeDescription
options{ account: Account; chain?: Chain; transport?: Transport; }Options for the PaymentsService
options.accountAccountViem account (required)
options.chain?ChainFilecoin chain (optional, defaults to DEFAULT_CHAIN)
options.transport?TransportViem transport (optional, defaults to http())

PaymentsService

A new PaymentsService instance