Skip to content

PaymentsService

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

new PaymentsService(
provider,
signer,
paymentsAddress,
usdfcAddress,
disableNonceManager): PaymentsService;

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

ParameterTypeDescription
providerProviderDirect provider instance for balance checks, nonce management, and epoch calculations
signerSignerSigner instance for transaction signing (may be wrapped in NonceManager)
paymentsAddressstringAddress of the Payments contract
usdfcAddressstringAddress of the USDFC token contract
disableNonceManagerbooleanWhen true, manually manages nonces using provider.getTransactionCount() Note: Both provider and signer are required for NonceManager compatibility. When NonceManager is disabled, we need direct provider access for reliable nonce management. Using signer.provider could interfere with NonceManager’s internal state or behave differently with MetaMask/hardware wallets.

PaymentsService

accountInfo(token): Promise<{
availableFunds: bigint;
funds: bigint;
lockupCurrent: bigint;
lockupLastSettledAt: bigint;
lockupRate: bigint;
}>;

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

Get detailed account information from the payments contract

ParameterTypeDefault valueDescription
tokenstringTOKENS.USDFCThe token to get account info for (defaults to USDFC)

Promise<{ availableFunds: bigint; funds: bigint; lockupCurrent: bigint; lockupLastSettledAt: bigint; lockupRate: bigint; }>

Account information including funds, lockup details, and available balance


allowance(spender, token): Promise<bigint>;

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

Check the current ERC20 token allowance for a spender

ParameterTypeDefault valueDescription
spenderstringundefinedThe address to check allowance for
tokenstringTOKENS.USDFCThe token to check allowance for (defaults to USDFC)

Promise<bigint>

The current allowance amount as bigint


approve(
spender,
amount,
token): Promise<TransactionResponse>;

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

Approve an ERC20 token spender

ParameterTypeDefault valueDescription
spenderstringundefinedThe address to approve as spender
amountTokenAmountundefinedThe amount to approve
tokenstringTOKENS.USDFCThe token to approve spending for (defaults to USDFC)

Promise<TransactionResponse>

Transaction response object


approveService(
service,
rateAllowance,
lockupAllowance,
maxLockupPeriod,
token): Promise<TransactionResponse>;

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

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

ParameterTypeDefault valueDescription
servicestringundefinedThe service contract address to approve
rateAllowanceTokenAmountundefinedMaximum payment rate per epoch the operator can set
lockupAllowanceTokenAmountundefinedMaximum lockup amount the operator can set
maxLockupPeriodTokenAmountundefinedMaximum lockup period in epochs the operator can set
tokenstringTOKENS.USDFCThe token to approve for (defaults to USDFC)

Promise<TransactionResponse>

Transaction response object


balance(token): Promise<bigint>;

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

ParameterTypeDefault value
tokenstringTOKENS.USDFC

Promise<bigint>


decimals(_token): number;

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

ParameterTypeDefault value
_tokenstringTOKENS.USDFC

number


deposit(
amount,
token,
callbacks?): Promise<TransactionResponse>;

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

ParameterTypeDefault value
amountTokenAmountundefined
tokenstringTOKENS.USDFC
callbacks?DepositCallbacksundefined

Promise<TransactionResponse>


depositWithPermit(
amount,
token,
deadline?): Promise<TransactionResponse>;

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

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.

ParameterTypeDefault valueDescription
amountTokenAmountundefinedAmount of USDFC to deposit (in base units)
tokenstringTOKENS.USDFCToken identifier (currently only USDFC is supported)
deadline?number | bigintundefinedUnix timestamp (seconds) when the permit expires. Defaults to now + 1 hour.

Promise<TransactionResponse>

Transaction response object


depositWithPermitAndApproveOperator(
amount,
operator,
rateAllowance,
lockupAllowance,
maxLockupPeriod,
token,
deadline?): Promise<TransactionResponse>;

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

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.

ParameterTypeDefault valueDescription
amountTokenAmountundefinedAmount of USDFC to deposit (in base units)
operatorstringundefinedService/operator address to approve
rateAllowanceTokenAmountundefinedMax payment rate per epoch operator can set
lockupAllowanceTokenAmountundefinedMax lockup amount operator can set
maxLockupPeriodTokenAmountundefinedMax lockup period in epochs operator can set
tokenstringTOKENS.USDFCToken identifier (currently only USDFC supported)
deadline?number | bigintundefinedUnix timestamp (seconds) when the permit expires. Defaults to now + 1 hour.

Promise<TransactionResponse>

Transaction response object


getRail(railId): Promise<{
commissionRateBps: bigint;
endEpoch: bigint;
from: string;
lockupFixed: bigint;
lockupPeriod: bigint;
operator: string;
paymentRate: bigint;
serviceFeeRecipient: string;
settledUpTo: bigint;
to: string;
token: string;
validator: string;
}>;

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

Get detailed information about a specific rail

ParameterTypeDescription
railIdnumber | bigintThe rail ID to query

Promise<{ commissionRateBps: bigint; endEpoch: bigint; from: string; lockupFixed: bigint; lockupPeriod: bigint; operator: string; paymentRate: bigint; serviceFeeRecipient: string; settledUpTo: bigint; to: string; token: string; validator: string; }>

Rail information including all parameters and current state

Error if the rail doesn’t exist or is inactive (contract reverts with RailInactiveOrSettled)


getRailsAsPayee(token): Promise<RailInfo[]>;

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

Get all rails where the wallet is the payee

ParameterTypeDefault valueDescription
tokenstringTOKENS.USDFCThe token to filter by (defaults to USDFC)

Promise<RailInfo[]>

Array of rail information


getRailsAsPayer(token): Promise<RailInfo[]>;

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

Get all rails where the wallet is the payer

ParameterTypeDefault valueDescription
tokenstringTOKENS.USDFCThe token to filter by (defaults to USDFC)

Promise<RailInfo[]>

Array of rail information


getSettlementAmounts(railId, untilEpoch?): Promise<SettlementResult>;

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

Get the expected settlement amounts for a rail (read-only simulation) Note: The actual settlement will require a network fee (FIL) to be sent with the transaction

ParameterTypeDescription
railIdnumber | bigintThe rail ID to check
untilEpoch?number | 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


revokeService(service, token): Promise<TransactionResponse>;

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

Revoke a service contract’s operator approval

ParameterTypeDefault valueDescription
servicestringundefinedThe service contract address to revoke
tokenstringTOKENS.USDFCThe token to revoke approval for (defaults to USDFC)

Promise<TransactionResponse>

Transaction response object


serviceApproval(service, token): Promise<{
isApproved: boolean;
lockupAllowance: bigint;
lockupUsed: bigint;
maxLockupPeriod: bigint;
rateAllowance: bigint;
rateUsed: bigint;
}>;

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

Get the operator approval status and allowances for a service

ParameterTypeDefault valueDescription
servicestringundefinedThe service contract address to check
tokenstringTOKENS.USDFCThe token to check approval for (defaults to USDFC)

Promise<{ isApproved: boolean; lockupAllowance: bigint; lockupUsed: bigint; maxLockupPeriod: bigint; rateAllowance: bigint; rateUsed: bigint; }>

Approval status and allowances


settle(railId, untilEpoch?): Promise<TransactionResponse>;

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

Settle a payment rail up to a specific epoch (sends a transaction) Note: This method automatically includes the required network fee (FIL) for burning

ParameterTypeDescription
railIdnumber | bigintThe rail ID to settle
untilEpoch?number | bigintThe epoch to settle up to (must be <= current epoch; defaults to current). Can be used for partial settlements to a past epoch.

Promise<TransactionResponse>

Transaction response object

Error if untilEpoch is in the future (contract reverts with CannotSettleFutureEpochs)


settleAuto(railId, untilEpoch?): Promise<TransactionResponse>;

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

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 (requires settlement fee)
ParameterTypeDescription
railIdnumber | bigintThe rail ID to settle
untilEpoch?number | bigintThe epoch to settle up to (must be <= current epoch for active rails; ignored for terminated rails)

Promise<TransactionResponse>

Transaction response object

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

// Automatically detect and settle appropriately
const tx = await synapse.payments.settleAuto(railId)
await tx.wait()
// For active rails, can specify epoch
const tx = await synapse.payments.settleAuto(railId, specificEpoch)

settleTerminatedRail(railId): Promise<TransactionResponse>;

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

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
railIdnumber | bigintThe rail ID to settle

Promise<TransactionResponse>

Transaction response object


walletBalance(token?): Promise<bigint>;

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

ParameterType
token?string

Promise<bigint>


withdraw(amount, token): Promise<TransactionResponse>;

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

ParameterTypeDefault value
amountTokenAmountundefined
tokenstringTOKENS.USDFC

Promise<TransactionResponse>