Skip to content

terminateServiceSync

terminateServiceSync(client, options): Promise<OutputType>

Defined in: packages/synapse-core/src/warm-storage/terminate-service.ts:125

Terminate a service (data set) and wait for confirmation

This function terminates a data set service, which will also result in the removal of all pieces in the data set. Waits for the transaction to be confirmed and returns the receipt with the ServiceTerminated event.

ParameterTypeDescription
clientClient<Transport, Chain, Account>The client to use to terminate the service.
options{ contractAddress?: `0x${string}`; dataSetId: bigint; onHash?: (hash) => void; }terminateServiceSync.OptionsType
options.contractAddress?`0x${string}`Warm storage contract address. If not provided, the default is the storage contract address for the chain.
options.dataSetIdbigintThe ID of the data set to terminate.
options.onHash?(hash) => voidCallback function called with the transaction hash before waiting for the receipt.

Promise<OutputType>

The transaction receipt and extracted event terminateServiceSync.OutputType

Errors terminateServiceSync.ErrorType

import { terminateServiceSync } from '@filoz/synapse-core/warm-storage'
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 terminateServiceSync(client, {
dataSetId: 1n,
onHash: (hash) => console.log('Transaction sent:', hash),
})
console.log('Data set ID:', event.args.dataSetId)