1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-11-22 09:47:06 +01:00

usePricing docs update

This commit is contained in:
Matthias Kretschmann 2020-10-19 13:03:36 +02:00
parent c7a355e6fa
commit a565e83220
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -1,19 +1,19 @@
# `usePricing`
Hook with helper utilities to create fixed price exchanges or liquidity pools for your data set, mint datatokens , buy and sell datatokens
Hook with helper utilities to create fixed price exchanges or liquidity pools for your data set, mint datatokens, and buy and sell datatokens.
## Usage
```tsx
import React from 'react'
import { useOcean, useCreatePricing } from '@oceanprotocol/react'
import { Metadata } from '@oceanprotocol/lib'
import { Metadata, DDO } from '@oceanprotocol/lib'
export default function MyComponent() {
export default function MyComponent({ ddo }: { ddo: DDO }) {
const { accountId } = useOcean()
const dataTokenAddress = '0x00000'
// Publish helpers
const { createPricing } = usePricing()
const { createPricing } = usePricing(ddo)
const priceOptions = {
price: 10,
@ -24,17 +24,17 @@ export default function MyComponent() {
}
async function handleCreatePricing() {
await createPricing(dataTokenAddress, priceOptions)
await createPricing(priceOptions)
}
async function handleMint() {
await mint(dataTokenAddress, '1')
await mint('1')
}
async function handleBuyDT() {
await buyDT(dataTokenAddress, '1')
await buyDT('1')
}
async function handleSellDT() {
await sellDT(dataTokenAddress, '1')
await sellDT('1')
}
return (
@ -44,7 +44,7 @@ export default function MyComponent() {
<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={handleBuyDT}>Buy DT</button>
<button onClick={handleSellDT}>Sell DT</button>
</div>
)