9d2c0f3c63
* Bump prettier from 2.2.1 to 2.3.0 Bumps [prettier](https://github.com/prettier/prettier) from 2.2.1 to 2.3.0. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/2.2.1...2.3.0) Signed-off-by: dependabot[bot] <support@github.com> * prettier updates Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Matthias Kretschmann <m@kretschmann.io> |
||
---|---|---|
.. | ||
PriceOptions.ts | ||
README.md | ||
index.ts | ||
usePricing.ts |
README.md
usePricing
Hook with helper utilities to create fixed price exchanges or liquidity pools for your data set, mint datatokens, and buy and sell datatokens.
Usage
import React from 'react'
import { useOcean, useCreatePricing } from '@oceanprotocol/react'
import { Metadata, DDO } from '@oceanprotocol/lib'
export default function MyComponent({ ddo }: { ddo: DDO }) {
const { accountId } = useOcean()
// Pricing helpers
const {
createPricing,
buyDT,
sellDT,
pricingStepText,
pricingError
} = usePricing(ddo)
const priceOptions = {
price: 10,
dtAmount: 10,
type: 'fixed',
weightOnDataToken: '',
swapFee: ''
}
async function handleCreatePricing() {
await createPricing(priceOptions)
}
async function handleMint() {
await mint('1')
}
async function handleBuyDT() {
await buyDT('1')
}
async function handleSellDT() {
await sellDT('1')
}
return (
<div>
<h1>Post for sale</h1>
<p>Your account: {accountId}</p>
<button onClick={handleMint}>Mint DT</button>
<button onClick={handleCreatePricing}>Post for sale</button>
<button onClick={handleBuyDT}>Buy DT</button>
<button onClick={handleSellDT}>Sell DT</button>
</div>
)
}