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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client | Client<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.dataSetId | bigint | The ID of the data set to terminate. |
options.onHash? | (hash) => void | Callback function called with the transaction hash before waiting for the receipt. |
Returns
Section titled “Returns”The transaction receipt and extracted event terminateServiceSync.OutputType
Throws
Section titled “Throws”Errors terminateServiceSync.ErrorType
Example
Section titled “Example”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)