addProduct
addProduct(
client,options):Promise<`0x${string}`>
Defined in: packages/synapse-core/src/sp-registry/add-product.ts:82
Add a product to the service provider
Adds a new product (e.g., PDP) to the calling provider’s offerings with the specified capabilities. Only the provider themselves can add products.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client | Client<Transport, Chain, Account> | The viem client with account to use for the transaction. |
options | OptionsType | addProduct.OptionsType |
Returns
Section titled “Returns”Promise<`0x${string}`>
The transaction hash addProduct.OutputType
Throws
Section titled “Throws”Errors addProduct.ErrorType
Example
Section titled “Example”import { addProduct } from '@filoz/synapse-core/sp-registry'import { createWalletClient, http, parseEther } 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 hash = await addProduct(client, { pdpOffering: { serviceURL: 'https://provider.example.com', minPieceSizeInBytes: 1024n, maxPieceSizeInBytes: 1073741824n, storagePricePerTibPerDay: parseEther('0.1'), minProvingPeriodInEpochs: 2880n, location: 'us-east', paymentTokenAddress: '0x0000000000000000000000000000000000000000', }, capabilities: { region: 'us-east', tier: 'premium' },})
console.log(hash)