mirror of
https://github.com/oceanprotocol/react.git
synced 2025-02-14 21:10:38 +01:00
add usePublish docs example
This commit is contained in:
parent
11058a61cc
commit
bd8df87715
48
src/hooks/usePublish/README.md
Normal file
48
src/hooks/usePublish/README.md
Normal 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>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user