Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/phase-2 #50

Merged
merged 58 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
dc07ab5
add simple flow Readme
alexcos20 May 22, 2020
15b010b
fix
alexcos20 May 22, 2020
7f967e7
fix
alexcos20 May 22, 2020
22e769e
Update README_simpleflow.md
alexcos20 May 22, 2020
f0eabe3
Update README_simpleflow.md
alexcos20 May 22, 2020
7366095
Update README_simpleflow.md
alexcos20 May 22, 2020
79f0784
Update README_simpleflow.md
alexcos20 May 22, 2020
1b219e9
Update README_simpleflow.md
alexcos20 May 22, 2020
7d34106
Create README_marketplace_flow.md
alexcos20 May 22, 2020
d098d5d
Update README_simpleflow.md
alexcos20 May 22, 2020
8a3faec
Update README_simpleflow.md
alexcos20 May 22, 2020
9a5fdb4
Update README_marketplace_flow.md
alexcos20 May 22, 2020
061ee0e
Update README_marketplace_flow.md
alexcos20 May 22, 2020
2e53c7d
minor rendering fix
May 22, 2020
5c80686
Merge pull request #11 from 0x3bfc/patch-1
alexcos20 May 22, 2020
552d976
fix lint errors
0x3bfc Jun 12, 2020
8efc5ee
Merge pull request #49 from oceanprotocol/feature/integrate-linter
Jun 12, 2020
ef93f07
Merge pull request #51 from oceanprotocol/feature/add_detailed_README
Jun 12, 2020
6e50ac9
init travis
0x3bfc Jun 12, 2020
34290c8
fix build:metadata
0x3bfc Jun 12, 2020
992096e
add oceanprotocol contracts
0x3bfc Jun 12, 2020
a0e4a8d
fix travis
0x3bfc Jun 16, 2020
f9c5dca
Merge pull request #52 from oceanprotocol/feature/travis
Jun 16, 2020
8aed213
integrate oceanprotocol/contracts
0x3bfc Jun 16, 2020
40cf27f
Merge pull request #63 from oceanprotocol/feature/contracts
Jun 16, 2020
b1e8f27
Create Dependabot config file
dependabot-preview[bot] Jun 16, 2020
ae995f3
Merge pull request #64 from oceanprotocol/dependabot/add-v2-config-file
Jun 16, 2020
77245a4
Bump typescript from 3.9.3 to 3.9.5
dependabot-preview[bot] Jun 16, 2020
96a9268
Bump auto-changelog from 2.0.0 to 2.1.0
dependabot-preview[bot] Jun 16, 2020
e5ed710
Merge pull request #65 from oceanprotocol/dependabot/npm_and_yarn/typ…
dependabot-preview[bot] Jun 16, 2020
14e3ef7
Bump mocha from 7.2.0 to 8.0.1
dependabot-preview[bot] Jun 16, 2020
819ffbb
Bump @types/node from 14.0.5 to 14.0.13
dependabot-preview[bot] Jun 16, 2020
7a33446
Bump web3 from 1.2.8 to 1.2.9
dependabot-preview[bot] Jun 16, 2020
e987b65
Merge pull request #66 from oceanprotocol/dependabot/npm_and_yarn/aut…
dependabot-preview[bot] Jun 16, 2020
a8b605e
Bump nyc from 15.0.1 to 15.1.0
dependabot-preview[bot] Jun 16, 2020
73e1e62
Bump ts-node from 8.10.1 to 8.10.2
dependabot-preview[bot] Jun 16, 2020
121fb5c
Merge pull request #67 from oceanprotocol/dependabot/npm_and_yarn/moc…
dependabot-preview[bot] Jun 16, 2020
83b69a8
Bump eslint-plugin-prettier from 3.1.3 to 3.1.4
dependabot-preview[bot] Jun 16, 2020
9663777
Merge pull request #68 from oceanprotocol/dependabot/npm_and_yarn/typ…
dependabot-preview[bot] Jun 16, 2020
e4e2078
Merge pull request #69 from oceanprotocol/dependabot/npm_and_yarn/web…
dependabot-preview[bot] Jun 16, 2020
7bd9da3
Merge pull request #70 from oceanprotocol/dependabot/npm_and_yarn/nyc…
dependabot-preview[bot] Jun 16, 2020
0696a1f
Merge pull request #71 from oceanprotocol/dependabot/npm_and_yarn/ts-…
dependabot-preview[bot] Jun 16, 2020
fbc58be
Merge pull request #72 from oceanprotocol/dependabot/npm_and_yarn/esl…
dependabot-preview[bot] Jun 16, 2020
7e8d455
Bump typescript from 3.9.3 to 3.9.5
dependabot-preview[bot] Jun 17, 2020
feff5aa
Bump mocha from 7.2.0 to 8.0.1
dependabot-preview[bot] Jun 17, 2020
7bf93b8
Bump ts-node from 8.10.1 to 8.10.2
dependabot-preview[bot] Jun 17, 2020
0cb9d31
Bump @release-it/bumper from 1.1.1 to 1.4.0
dependabot-preview[bot] Jun 17, 2020
3fa0080
Bump prettier from 1.19.1 to 2.0.5
dependabot-preview[bot] Jun 17, 2020
1581516
Merge pull request #73 from oceanprotocol/dependabot/npm_and_yarn/typ…
dependabot-preview[bot] Jun 17, 2020
1ac2510
Merge pull request #74 from oceanprotocol/dependabot/npm_and_yarn/moc…
dependabot-preview[bot] Jun 17, 2020
a47c7ee
Merge pull request #75 from oceanprotocol/dependabot/npm_and_yarn/ts-…
dependabot-preview[bot] Jun 17, 2020
a65e940
Merge branch 'feature/cleaning' into dependabot/npm_and_yarn/release-…
Jun 17, 2020
9f6b976
Merge pull request #77 from oceanprotocol/dependabot/npm_and_yarn/pre…
dependabot-preview[bot] Jun 17, 2020
11c73e8
Merge pull request #76 from oceanprotocol/dependabot/npm_and_yarn/rel…
Jun 17, 2020
92005c6
fix imports
0x3bfc Jun 17, 2020
de09819
fix lint errors
0x3bfc Jun 17, 2020
04c75d9
restructure interfaces
0x3bfc Jun 17, 2020
5df40ce
Merge pull request #78 from oceanprotocol/feature/datatoken
Jun 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: '03:00'
timezone: Europe/Berlin
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
dist: xenial
sudo: required
language: node_js
node_js:
- '12'

services:
- docker

cache: npm

matrix:
fast_finish: true

before_install:
- npm install -g npm
- npm install -g ganache-cli@~6.5.1

before_script:
- ganache-cli --port 18545 > ganache-cli.log &

script:
- npm run lint
- npm run build

notifications:
email: false
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![banner](https://raw.githubusercontent.com/oceanprotocol/art/master/github/repo-banner%402x.png)](https://oceanprotocol.com)

|[![Build Status](https://travis-ci.com/oceanprotocol/lib-js.svg?token=soMi2nNfCZq19zS1Rx4i&branch=develop)](https://travis-ci.com/oceanprotocol/lib-js)

<h1 align="center">Ocean-js</h1>

Expand Down
154 changes: 154 additions & 0 deletions README_marketplace_flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# ocean-lib


`ocean-lib-js` is a Javascript/Typescript library to privately & securely publish, exchange, and consume data. With it, you can:
* **Publish** data services: static data, streaming data, or compute-to-data. Every data service gets its own [ERC20](https://github.com/ethereum/EIPs/blob/7f4f0377730f5fc266824084188cc17cf246932e/EIPS/eip-20.md) token.
* **Mint** data tokens for a given data service
* **Transfer** data tokens to another owner
* **Consume** data tokens, to access the service

`ocean-lib-js` is part of the [Ocean Protocol](www.oceanprotocol.com) toolset.

# Installation
```
// ES6
import { Ocean, Logger } from '@oceanprotocol/lib'

// ES2015
const { Ocean, Logger } = require('@oceanprotocol/lib')

```

# Quickstart

This section describes a marketplace flow with multiple services

Here's the steps.
1. Alice publishes a dataset (= publishes a datatoken contract)
1. Alice mints 100 tokens
1. Alice transfers 1 token to Bob
1. Bob consumes dataset

Let's go through each of these in detail.


## 1. Alice hosts the dataset

A locally providerService ,metadatastore and marketplace are required:

Run the providerService and metadatastore:
```
docker run @oceanprotocol/provider-py:latest
docker run @oceanprotocol/aquarius:latest
docker run @oceanprotocol/marketplace:latest
```


## 2. Alice publishes a dataset (= publishes a datatoken contract)

For now, you're Alice:) Let's proceed.


```javascript
const { Ocean, Logger } = require('@oceanprotocol/lib')

const marketPlaceAddress='0x9876'
//Alice's config
const config={
network: 'rinkeby',
privateKey:'8da4ef21b864d2cc526dbdb2a120bd2874c36c9d0a1fb7f8c63d7f7a8b41de8f',
metadataStoreURI: 'localhost:5000',
providerUri: 'localhost:8030'
}
const ocean = Ocean(alice_config)
const account = await ocean.accounts.list()[0]


const myToken = ocean.datatoken.create(config.metadataStoreURI,account)
//Alice allows MarketPlace to transfer 20 DT
myToken.approve(marketPlaceAddress,20)

const dt_address=myToken.getAddress()

//create asset 1
const metaData={
"did":"did:op:1234",
"owner":"0xaaaaa",
"dtAddress":dt_address,
"name":"Asset1",
"services="[
{ "id":0, "serviceEndpoint":"providerUri", "type":"download", "dtCost":10, "timeout":0,
"files":[{"url":"http://example.net"},{"url":"http://example.com" }]
},
{ "id":1, "type":"compute", "serviceEndpoint":"providerUri", "dtCost":1,"timeout":3600},
{ "id":2, "type":"compute", "serviceEndpoint":"providerUri", "dtCost":2, "timeout":7200 },
]
}
//create will encrypt the URLs using publisher and update the ddo before pushing to aquarius
//create will require that metaData.dtAddress is a valid DT Contract address
const asset = ocean.assets.create(metaData,account)
const did = asset.did
```



## 3. Alice mints 100 tokens

```javascript
myToken.mint(100)
```

## 4. Exchange of value : How Bob gets DT
```javascript
const bob_config={
network: 'rinkeby',
privateKey:'1234ef21b864d2cc526dbdb2a120bd2874c36c9d0a1fb7f8c63d7f7a8b41de8f'
marketPlaceUri: 'localhost:3000'
}
const bob_ocean = Ocean(bob_config)
const bob_account = await bob_ocean.accounts.list()[0]

const asset = ocean.assets.resolve(did)
const serviceIndex = assets.findServiceByType('compute')
const num_dt_needed = assets.getDtCost(serviceIndex)
//Bob need to buy num_dt_needed . DTAddress = asset.dtAddress

const {price, currency } = ocean.marketplace.getPrice(num_dt_needed,asset.dtAddress)
bob_account.approve(price, currency, marketPlaceAddress)
ocean.marketplace.buy(num_dt_needed,asset.dtAddress)
```

## 5. Bob consumes dataset

Now, you are Bob :)


```javascript

const bob_config={
network: 'rinkeby',
privateKey:'1234ef21b864d2cc526dbdb2a120bd2874c36c9d0a1fb7f8c63d7f7a8b41de8f'
}
const bob_ocean = Ocean(bob_config)


const account = await bob_ocean.accounts.list()[0]
const asset = ocean.assets.getFromDID(did)
const serviceIndex = assets.findServiceByType('compute')

export const rawAlgoMeta = {
rawcode: `console.log('Hello world'!)`,
format: 'docker-image',
version: '0.1',
container: {
entrypoint: 'node $ALGO',
image: 'node',
tag: '10'
}
}

const computeJob=asset.StartCompute(serviceIndex, rawAlgoMeta, account)

```


102 changes: 102 additions & 0 deletions README_simpleflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@

# ocean-lib

`ocean-lib-js` is a Javascript/Typescript library to privately & securely publish, exchange, and consume data. With it, you can:
* **Publish** data services: static data, streaming data, or compute-to-data. Every data service gets its own [ERC20](https://github.com/ethereum/EIPs/blob/7f4f0377730f5fc266824084188cc17cf246932e/EIPS/eip-20.md) token.
* **Mint** data tokens for a given data service
* **Transfer** data tokens to another owner
* **Consume** data tokens, to access the service

`ocean-lib-js` is part of the [Ocean Protocol](www.oceanprotocol.com) toolset.

# Installation
```
// ES6
import { Ocean, Logger } from '@oceanprotocol/lib'

// ES2015
const { Ocean, Logger } = require('@oceanprotocol/lib')

```

# Quickstart

This section describes a flow with the simplest transfer of value, for static data.

Here's the steps.
1. Alice publishes a dataset (= publishes a datatoken contract)
1. Alice mints 100 tokens
1. Alice transfers 1 token to Bob
1. Bob consumes dataset

Let's go through each of these in detail.


## 1. Alice publishes a dataset (= publishes a datatoken contract)

For now, you're Alice:) Let's proceed.


```javascript
const { Ocean, Logger } = require('@oceanprotocol/lib')
const config={
network: 'rinkeby',
privateKey:'8da4ef21b864d2cc526dbdb2a120bd2874c36c9d0a1fb7f8c63d7f7a8b41de8f',
}
const ocean = Ocean(alice_config)
const account = await ocean.accounts.list()[0]
const myToken = ocean.datatoken.create('localhost:8030',account)
const dt_address=myToken.getAddress()
console.log(dt_address)
```

## 2. Alice hosts the dataset

A locally providerService is required, which will serve just one file for this demo.
Let's create the file to be shared:
```
touch /var/mydata/myFolder1/file
````

Run the providerService:
(given that ERC20 contract address from the above is 0x1234)

```
ENV DT="{'0x1234':'/var/mydata/myFolder1'}"
docker run @oceanprotocol/provider-py -e CONFIG=DT
```


## 3. Alice mints 100 tokens

```javascript
myToken.mint(100)
```

## 4. Alice transfers 1 token to Bob

```javascript
myToken.transfer(1,BobAddress)
```

## 5. Bob consumes dataset

Now, you are Bob :)


```javascript

const bob_config={
network: 'rinkeby',
privateKey:'1234ef21b864d2cc526dbdb2a120bd2874c36c9d0a1fb7f8c63d7f7a8b41de8f'
}
const bob_ocean = Ocean(bob_config)


const account = await bob_ocean.accounts.list()[0]
const asset=bob_ocean.assets.getFromDTAddress(dt_address)[0]
const file=asset.download(account)

```


Loading