initial concept

This commit is contained in:
Matthias Kretschmann 2020-04-24 16:38:24 +02:00
commit c7558bd769
Signed by: m
GPG Key ID: 606EEEF3C479A91F
1 changed files with 42 additions and 0 deletions

42
README.md Normal file
View File

@ -0,0 +1,42 @@
# @oceanprotocol/react
> React hooks & components on top of squid.js
## Installation
```bash
npm install @oceanprotocol/react
```
## Usage
```tsx
import React from 'react'
import { useOcean, OceanConfig, useConsume } from '@oceanprotocol/react'
const oceanConfig: OceanConfig = {
nodeUri: '',
...
}
export default function MyComponent() {
// TODO: setup web3 first
const { ocean, account } = useOcean(web3, oceanConfig)
const { consumeAsset, isLoading, step } = useConsume()
async function handleClick() {
const ddo = 'did:op:0x000000000'
await consumeAsset(ddo)
}
return (
<div>
Your account: {account}
<button onClick={handleClick}>
{isLoading ? step : 'Download Asset' }
</button>
</div>
)
}
```