1
0
mirror of https://github.com/oceanprotocol/react.git synced 2025-02-14 21:10:38 +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` # `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 ## Usage
```tsx ```tsx
import React from 'react' import React from 'react'
import { useOcean, useCreatePricing } from '@oceanprotocol/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 { accountId } = useOcean()
const dataTokenAddress = '0x00000'
// Publish helpers // Publish helpers
const { createPricing } = usePricing() const { createPricing } = usePricing(ddo)
const priceOptions = { const priceOptions = {
price: 10, price: 10,
@ -24,17 +24,17 @@ export default function MyComponent() {
} }
async function handleCreatePricing() { async function handleCreatePricing() {
await createPricing(dataTokenAddress, priceOptions) await createPricing(priceOptions)
} }
async function handleMint() { async function handleMint() {
await mint(dataTokenAddress, '1') await mint('1')
} }
async function handleBuyDT() { async function handleBuyDT() {
await buyDT(dataTokenAddress, '1') await buyDT('1')
} }
async function handleSellDT() { async function handleSellDT() {
await sellDT(dataTokenAddress, '1') await sellDT('1')
} }
return ( return (
@ -44,7 +44,7 @@ export default function MyComponent() {
<p>Your account: {accountId}</p> <p>Your account: {accountId}</p>
<button onClick={handleMint}>Mint DT</button> <button onClick={handleMint}>Mint DT</button>
<button onClick={handleCreatePricing}>Post for sale</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> <button onClick={handleSellDT}>Sell DT</button>
</div> </div>
) )