react/src/hooks/usePublish
Matthias Kretschmann e22212bd01
package updates, linting fixes
2020-09-15 21:57:44 +02:00
..
DataTokenOptions.ts lib update 2020-09-07 17:25:31 +03:00
PriceOptions.ts prepare strict type checking, bunch of typing fixes 2020-09-15 21:28:27 +02:00
README.md add usePublish docs example 2020-09-07 16:44:34 +02:00
index.ts lib update 2020-09-07 17:25:31 +03:00
usePublish.ts package updates, linting fixes 2020-09-15 21:57:44 +02:00

README.md

usePublish

Publish data sets, and create data tokens and liquidity pools for them.

Usage

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>
  )
}