Skip to content

terminateService

terminateService(client, options): Promise<OutputType>

Defined in: packages/synapse-core/src/sp/terminate-service.ts:231

Terminate a data set service via the service provider

Signs a termination authorization and sends it to the provider, which relays it on chain. Provider-relayed termination takes effect immediately when the transaction lands (no lockup wind-down); it fails instead if the payer’s account cannot settle in full. The direct on-chain alternative (warm-storage/terminate-service) needs no provider cooperation but the service runs to the end of the lockup period.

ParameterTypeDescription
clientClient<Transport, Chain, Account>The client to use to sign the termination authorization.
optionsOptionsTypeterminateService.OptionsType

Promise<OutputType>

Status URL to poll with waitForTerminateService. terminateService.OutputType

Errors terminateService.ErrorType

import { terminateService, waitForTerminateService } from '@filoz/synapse-core/sp'
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 { statusUrl } = await terminateService(client, {
dataSetId: 1n,
serviceURL: 'https://pdp.example.com',
})
const status = await waitForTerminateService({ statusUrl })
console.log(status.serviceTerminationEpoch)