1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-11-23 02:00:27 +01:00

add usePublish docs example

This commit is contained in:
Matthias Kretschmann 2020-09-07 16:42:56 +02:00
parent 11058a61cc
commit bd8df87715
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -0,0 +1,48 @@
# `usePublish`
Publish data sets, and create data tokens and liquidity pools for them.
## Usage
```tsx
import React from 'react'
import { useOcean, usePublish } from '@oceanprotocol/react'
import { Metadata } from '@oceanprotocol/lib'
export default function MyComponent() {
const { accountId } = useOcean()
// Publish helpers
const { publish, publishStep } = usePublish()
const metadata: MetaData = {
main: {
name: 'Asset'
},
additionalInformation: {
description: 'My Cool Asset'
}
}
const priceOptions = {
price: 10,
tokensToMint: 10,
type: 'fixed',
weightOnDataToken: '',
liquidityProviderFee: ''
}
async function handlePublish() {
const ddo = await publish(metadata, priceOptions, 'access')
}
return (
<div>
<h1>Publish</h1>
<p>Your account: {accountId}</p>
<button onClick={handlePublish}>Publish</button>
</div>
)
}
```