Skip to content
LogoLogo

Pricing

What a service costs, read from the chain

v1 read prices from the Ocean subgraph. That is gone — Config has no subgraphUri at all any more, and nautilus no longer depends on urql or graphql. Prices now come from contract reads, the same way ocean.js derives them.

For most flows you never need this: access orders whatever is required. Reach for it when you want to show a price before committing to a purchase.

Two steps

Pricing is read in two calls: what scheme the datatoken uses, then what one order costs.

const  = await .('did:ope:1234abcd...')
const  = ()[0].
const  = (, ) as string
 
const  = .()
const  = .()
 
const  = await (, , ) 
const  = await (, , ) 
 
.(.)

PricingInfo

FieldMeaning
schema'fixed', 'free' or 'none'
templateIdDatatoken template: 1 basic, 2 enterprise, 4 confidential EVM
datatokenAddressThe token being priced
exchangeIdThe fixed-rate exchange id, when schema is 'fixed'
baseTokenAddressWhat the exchange charges in
baseTokenDecimalsDecimals of that token
publishMarketFeeThe publisher's market fee

OrderPrice

Every field is a decimal string.

FieldMeaning
totalThe base-token spend — what the exchange takes
baseTokenAmountThe same amount, named for what it is
opcFeeOcean Protocol Community fee
publishMarketFeeThe publishing market's cut, in its own token
consumeMarketFeeWhat your market collects, if you charge anything
consumeMarketThe { address, fee } this quote was priced with

total already contains every swap-side fee, so never sum the fields yourself.

Charging a consume-market fee

Your cut is a fraction of the swap, not an amount — '0.01' is 1% — and it needs the account that collects it. The exchange pays its swap fee to whichever address the order names, so a fee without a collector is either lost or paid to somebody else.

const  = await (, , , {
  : '0xYourMarketCollector', 
  : '0.01' // 1% of the swap
})
 
// `price` carries the fee, so the order charges what was quoted, to the address it was
// quoted for.
await ({ , , , , : 0, ,  })

Do you already hold an order?

hasReusableOrder answers from what the node reports, rather than reconstructing it from events — the node returns validOrder when a previous order is still inside the service's timeout.

if (()) {
  // Already paid, still inside the timeout — no new order needed.
}

Coming from v1

v1v2
getAccessDetails()getPricingInfo()
AccessDetailsPricingInfo
OrderPriceAndFeesOrderPrice
AssetWithAccessDetails— read pricing separately from the asset
subgraph queriescontract reads

Try it

npm start -- access:price did:ope:…      # what an asset costs right now
npm start -- edit:price did:ope:… 2.95   # reprice a fixed-rate exchange

config.ts in examples/ holds ready-made pricing configs per network, with the payment-token addresses already filled in.