Skip to content
LogoLogo

setServicePrice

Change the price of a fixed-rate service, without republishing the DDO.

Usage

const  = await .('did:ope:2a6ebce0af...')
const  = ()[0].
 
const  = await .(, , '2.5') 

This is the right way to reprice a published service. Doing it through the ServiceBuilder is deliberately blocked, because a new pricing config mints a new datatoken and so changes the service id.

The fixed-rate exchange id is read from chain — v1 read it from the Ocean subgraph, which the current stack no longer runs.

Returns

  • Type: TransactionReceipt

The setRate transaction.

Throws

  • if newPrice is not a numeric string
  • if the asset has no service with that id
  • if the service is priced by a dispenser rather than a fixed-rate exchange — a free service has no rate to set

Parameters

asset

  • Type: AssetV5

The resolved asset, from getAsset.

serviceId

  • Type: string

newPrice

  • Type: string

A numeric string, e.g. '2.5'.