@oceanprotocol/lib 5.0.3 → 5.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -1
- package/Cheatsheet.md +326 -0
- package/CodeExamples.md +2 -2
- package/ComputeExamples.md +3 -3
- package/README.md +33 -7
- package/dist/lib.cjs +1 -1
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.modern.js +1 -1
- package/dist/lib.modern.js.map +1 -1
- package/dist/lib.module.mjs +1 -1
- package/dist/lib.module.mjs.map +1 -1
- package/dist/lib.umd.js +1 -1
- package/dist/lib.umd.js.map +1 -1
- package/dist/types/@types/Compute.d.ts +7 -0
- package/dist/types/config/Config.d.ts +6 -0
- package/dist/types/contracts/EnterpriseFeeCollector.d.ts +33 -0
- package/dist/types/contracts/index.d.ts +1 -0
- package/dist/types/services/Provider.d.ts +4 -2
- package/dist/types/utils/index.d.ts +1 -0
- package/docs/README.md +10 -7
- package/docs/classes/Escrow.md +285 -0
- package/docs/classes/Provider.md +75 -10
- package/docs/interfaces/ComputeEnvironment.md +68 -75
- package/docs/interfaces/ComputeJob.md +34 -1
- package/docs/interfaces/ComputeResourcesRequest.md +6 -2
- package/docs/interfaces/ProviderComputeInitializeResults.md +14 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,12 +4,36 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [v5.0.5](https://github.com/oceanprotocol/ocean.js/compare/v5.0.4...v5.0.5)
|
|
8
|
+
|
|
9
|
+
- Deps/bump_contracts_to_2_5_0 [`#2016`](https://github.com/oceanprotocol/ocean.js/pull/2016)
|
|
10
|
+
- export addrs functions [`#2018`](https://github.com/oceanprotocol/ocean.js/pull/2018)
|
|
11
|
+
- Feature/fix enterprise fee [`#2014`](https://github.com/oceanprotocol/ocean.js/pull/2014)
|
|
12
|
+
- Feature/add enterprisefee getters [`#2010`](https://github.com/oceanprotocol/ocean.js/pull/2010)
|
|
13
|
+
- fix resources & add queue [`#2009`](https://github.com/oceanprotocol/ocean.js/pull/2009)
|
|
14
|
+
- add escrow address to config [`#2008`](https://github.com/oceanprotocol/ocean.js/pull/2008)
|
|
15
|
+
- Update docs [`#2006`](https://github.com/oceanprotocol/ocean.js/pull/2006)
|
|
16
|
+
- update codeowners [`#2005`](https://github.com/oceanprotocol/ocean.js/pull/2005)
|
|
17
|
+
|
|
18
|
+
#### [v5.0.4](https://github.com/oceanprotocol/ocean.js/compare/v5.0.3...v5.0.4)
|
|
19
|
+
|
|
20
|
+
> 17 October 2025
|
|
21
|
+
|
|
22
|
+
- add envs and termination details [`#2004`](https://github.com/oceanprotocol/ocean.js/pull/2004)
|
|
23
|
+
- Add Cheatsheet. [`#2001`](https://github.com/oceanprotocol/ocean.js/pull/2001)
|
|
24
|
+
- Add support for BASE network. [`#2002`](https://github.com/oceanprotocol/ocean.js/pull/2002)
|
|
25
|
+
- Bump ddo.js to 0.1.4. [`#1996`](https://github.com/oceanprotocol/ocean.js/pull/1996)
|
|
26
|
+
- Release 5.0.4 [`59f305b`](https://github.com/oceanprotocol/ocean.js/commit/59f305b906c02f9d7dad7863733e0d516f8d6f9e)
|
|
27
|
+
|
|
7
28
|
#### [v5.0.3](https://github.com/oceanprotocol/ocean.js/compare/v5.0.2...v5.0.3)
|
|
8
29
|
|
|
30
|
+
> 23 September 2025
|
|
31
|
+
|
|
9
32
|
- Bump sha.js from 2.4.11 to 2.4.12 [`#1989`](https://github.com/oceanprotocol/ocean.js/pull/1989)
|
|
10
33
|
- Bump @types/node from 22.15.29 to 24.3.0 [`#1992`](https://github.com/oceanprotocol/ocean.js/pull/1992)
|
|
11
34
|
- extend metadata interface [`#1993`](https://github.com/oceanprotocol/ocean.js/pull/1993)
|
|
12
35
|
- Bump tmp and @inquirer/editor [`#1985`](https://github.com/oceanprotocol/ocean.js/pull/1985)
|
|
36
|
+
- Release 5.0.3 [`d046872`](https://github.com/oceanprotocol/ocean.js/commit/d046872003bab4092d6cc50de4d32d2cdf72dc4c)
|
|
13
37
|
|
|
14
38
|
#### [v5.0.2](https://github.com/oceanprotocol/ocean.js/compare/v5.0.1...v5.0.2)
|
|
15
39
|
|
|
@@ -61,7 +85,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
61
85
|
- Feature/contracts_240 [`#1979`](https://github.com/oceanprotocol/ocean.js/pull/1979)
|
|
62
86
|
- Release 5.0.0-next.2 [`fedd4c2`](https://github.com/oceanprotocol/ocean.js/commit/fedd4c273d86fb3f85990d7a289be4c3a4270832)
|
|
63
87
|
|
|
64
|
-
#### [v5.0.0-next.1](https://github.com/oceanprotocol/ocean.js/compare/v4.3.
|
|
88
|
+
#### [v5.0.0-next.1](https://github.com/oceanprotocol/ocean.js/compare/v4.3.6...v5.0.0-next.1)
|
|
65
89
|
|
|
66
90
|
> 1 August 2025
|
|
67
91
|
|
|
@@ -72,6 +96,30 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
72
96
|
- Feature/update ethers [`#1969`](https://github.com/oceanprotocol/ocean.js/pull/1969)
|
|
73
97
|
- Release 5.0.0-next.1 [`cf92038`](https://github.com/oceanprotocol/ocean.js/commit/cf92038208679177ab6af112526f5547feb0f11e)
|
|
74
98
|
|
|
99
|
+
#### [v4.3.6](https://github.com/oceanprotocol/ocean.js/compare/v4.3.5...v4.3.6)
|
|
100
|
+
|
|
101
|
+
> 24 November 2025
|
|
102
|
+
|
|
103
|
+
- export util addrs functions [`#2017`](https://github.com/oceanprotocol/ocean.js/pull/2017)
|
|
104
|
+
- Release 4.3.6 [`b28db44`](https://github.com/oceanprotocol/ocean.js/commit/b28db446144939e9ed864cc11559f718104d094b)
|
|
105
|
+
|
|
106
|
+
#### [v4.3.5](https://github.com/oceanprotocol/ocean.js/compare/v4.3.4...v4.3.5)
|
|
107
|
+
|
|
108
|
+
> 17 November 2025
|
|
109
|
+
|
|
110
|
+
- V4/feature/enterprise fee collector [`#2011`](https://github.com/oceanprotocol/ocean.js/pull/2011)
|
|
111
|
+
- Release 4.3.5 [`2953f4a`](https://github.com/oceanprotocol/ocean.js/commit/2953f4ac49d56ac8b066ad8fa7a71b6bbc0df005)
|
|
112
|
+
- remove typo [`f199f4a`](https://github.com/oceanprotocol/ocean.js/commit/f199f4af809eb85249fe0c59303fcc3207d8e7a7)
|
|
113
|
+
- export EnterpriseFeeCollector [`68712a2`](https://github.com/oceanprotocol/ocean.js/commit/68712a2af17824bb8fc78824842376e35f582487)
|
|
114
|
+
|
|
115
|
+
#### [v4.3.4](https://github.com/oceanprotocol/ocean.js/compare/v4.3.3...v4.3.4)
|
|
116
|
+
|
|
117
|
+
> 15 November 2025
|
|
118
|
+
|
|
119
|
+
- add EnterpriseFee [`b502882`](https://github.com/oceanprotocol/ocean.js/commit/b502882d05375eda326166608730a11e779c6f42)
|
|
120
|
+
- Release 4.3.4 [`e45a7de`](https://github.com/oceanprotocol/ocean.js/commit/e45a7defa239f6800eb68a13e1a9a3d9662f509d)
|
|
121
|
+
- bump contracts [`0b226a1`](https://github.com/oceanprotocol/ocean.js/commit/0b226a107f309c6b200249d498ae7568343fcb92)
|
|
122
|
+
|
|
75
123
|
#### [v4.3.3](https://github.com/oceanprotocol/ocean.js/compare/v4.3.2...v4.3.3)
|
|
76
124
|
|
|
77
125
|
> 1 August 2025
|
package/Cheatsheet.md
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
# Ocean.js Cheatsheet
|
|
2
|
+
|
|
3
|
+
## Prerequisites
|
|
4
|
+
- Git, Node.js, Docker
|
|
5
|
+
- Install Git: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
|
|
6
|
+
- Node.js: https://nodejs.org/en/download/
|
|
7
|
+
- Docker: https://docs.docker.com/get-docker/
|
|
8
|
+
|
|
9
|
+
### Installation & Usage
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm init
|
|
13
|
+
npm install @oceanprotocol/lib crypto-js ethers typescript @types/node ts-node
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Configuration
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
export NODE_URL='https://compute1.oceanprotocol.com'
|
|
20
|
+
export PRIVATE_KEY=<replace_me>
|
|
21
|
+
export RPC=<replace_me>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Publish Flow
|
|
25
|
+
|
|
26
|
+
1. Define DDO object
|
|
27
|
+
```javascript
|
|
28
|
+
|
|
29
|
+
const genericAsset: DDO = {
|
|
30
|
+
'@context': ['https://w3id.org/did/v1'],
|
|
31
|
+
id: 'did:op',
|
|
32
|
+
version: '4.1.0',
|
|
33
|
+
chainId: 8996,
|
|
34
|
+
nftAddress: '0x0',
|
|
35
|
+
metadata: {
|
|
36
|
+
created: '2021-12-20T14:35:20Z',
|
|
37
|
+
updated: '2021-12-20T14:35:20Z',
|
|
38
|
+
type: 'dataset',
|
|
39
|
+
name: 'dataset-name',
|
|
40
|
+
description: 'Ocean protocol test dataset description',
|
|
41
|
+
author: 'oceanprotocol-team',
|
|
42
|
+
license: 'MIT',
|
|
43
|
+
tags: ['white-papers'],
|
|
44
|
+
additionalInformation: { 'test-key': 'test-value' },
|
|
45
|
+
links: ['http://data.ceda.ac.uk/badc/ukcp09/']
|
|
46
|
+
},
|
|
47
|
+
services: [
|
|
48
|
+
{
|
|
49
|
+
id: 'db164c1b981e4d2974e90e61bda121512e6909c1035c908d68933ae4cfaba6b0',
|
|
50
|
+
type: 'access',
|
|
51
|
+
files: '',
|
|
52
|
+
datatokenAddress: '0xa15024b732A8f2146423D14209eFd074e61964F3',
|
|
53
|
+
serviceEndpoint: 'http://127.0.0.1:8001',
|
|
54
|
+
timeout: 0
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
2. Create NFT + datatoken + dispenser/FRE:
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
|
|
63
|
+
const { chainId } = await publisherAccount.provider.getNetwork()
|
|
64
|
+
const factory = new NftFactory(
|
|
65
|
+
addresses.ERC721Factory,
|
|
66
|
+
publisherAccount,
|
|
67
|
+
Number(chainId)
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
const nftParams: NftCreateData = {
|
|
71
|
+
name: FRE_NFT_NAME,
|
|
72
|
+
symbol: FRE_NFT_SYMBOL,
|
|
73
|
+
templateIndex: 1,
|
|
74
|
+
tokenURI: '',
|
|
75
|
+
transferable: true,
|
|
76
|
+
owner: await publisherAccount.getAddress()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const datatokenParams: DatatokenCreateParams = {
|
|
80
|
+
templateIndex: 1,
|
|
81
|
+
cap: '100000',
|
|
82
|
+
feeAmount: '0',
|
|
83
|
+
paymentCollector: ZERO_ADDRESS,
|
|
84
|
+
feeToken: ZERO_ADDRESS,
|
|
85
|
+
minter: await publisherAccount.getAddress(),
|
|
86
|
+
mpFeeAddress: ZERO_ADDRESS
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const freParams: FreCreationParams = {
|
|
90
|
+
fixedRateAddress: addresses.FixedPrice,
|
|
91
|
+
baseTokenAddress: addresses.Ocean,
|
|
92
|
+
owner: await publisherAccount.getAddress(),
|
|
93
|
+
marketFeeCollector: await publisherAccount.getAddress(),
|
|
94
|
+
baseTokenDecimals: 18,
|
|
95
|
+
datatokenDecimals: 18,
|
|
96
|
+
fixedRate: '1',
|
|
97
|
+
marketFee: '0.001',
|
|
98
|
+
allowedConsumer: ZERO_ADDRESS,
|
|
99
|
+
withMint: true
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const bundleNFT = await factory.createNftWithDatatokenWithFixedRate(
|
|
103
|
+
nftParams,
|
|
104
|
+
datatokenParams,
|
|
105
|
+
freParams
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
### Consume Flow
|
|
110
|
+
As a prerequisite for this flow, publish flow needs to be executed before.
|
|
111
|
+
```javascript
|
|
112
|
+
const fixedRate = new FixedRateExchange(freAddress, consumerAccount, Number(chainId))
|
|
113
|
+
await fixedRate.buyDatatokens(freId, '1', '2')
|
|
114
|
+
|
|
115
|
+
const resolvedDDO = await aquarius.waitForIndexer(fixedDDO.id)
|
|
116
|
+
assert(resolvedDDO, 'Cannot fetch DDO from Aquarius')
|
|
117
|
+
|
|
118
|
+
// Initialize - obtain proof for ordering assets
|
|
119
|
+
|
|
120
|
+
const initializeData = await ProviderInstance.initialize(
|
|
121
|
+
resolvedDDO.id,
|
|
122
|
+
resolvedDDO.services[0].id,
|
|
123
|
+
0,
|
|
124
|
+
await consumerAccount.getAddress(),
|
|
125
|
+
providerUrl
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
const providerFees: ProviderFees = {
|
|
129
|
+
providerFeeAddress: initializeData.providerFee.providerFeeAddress,
|
|
130
|
+
providerFeeToken: initializeData.providerFee.providerFeeToken,
|
|
131
|
+
providerFeeAmount: initializeData.providerFee.providerFeeAmount,
|
|
132
|
+
v: initializeData.providerFee.v,
|
|
133
|
+
r: initializeData.providerFee.r,
|
|
134
|
+
s: initializeData.providerFee.s,
|
|
135
|
+
providerData: initializeData.providerFee.providerData,
|
|
136
|
+
validUntil: initializeData.providerFee.validUntil
|
|
137
|
+
}
|
|
138
|
+
// Starting order after retriving provider fees
|
|
139
|
+
const tx = await datatoken.startOrder(
|
|
140
|
+
freDatatokenAddress,
|
|
141
|
+
await consumerAccount.getAddress(),
|
|
142
|
+
0,
|
|
143
|
+
providerFees
|
|
144
|
+
)
|
|
145
|
+
const orderTx = await tx.wait()
|
|
146
|
+
const orderStartedTx = getEventFromTx(orderTx, 'OrderStarted')
|
|
147
|
+
console.log(`Order started, tx: ${orderStartedTx.transactionHash}`)
|
|
148
|
+
|
|
149
|
+
const downloadURL = await ProviderInstance.getDownloadUrl(
|
|
150
|
+
fixedDDO.id,
|
|
151
|
+
fixedDDO.services[0].id,
|
|
152
|
+
0,
|
|
153
|
+
orderStartedTx.transactionHash,
|
|
154
|
+
providerUrl,
|
|
155
|
+
consumerAccount
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
// Lets check that the download URL was successfully received
|
|
159
|
+
console.log(`Download URL: ${downloadURL}`)
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
For better UX, it is recommended to have installed VSCode extension.
|
|
163
|
+
### Get compute environments
|
|
164
|
+
|
|
165
|
+
```javascript
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
// Fetch compute envrionments first
|
|
169
|
+
const computeEnvs = await ProviderInstance.getComputeEnvironments(providerUrl)
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
For `free start compute` it is not necessary publish flow.
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
### Free Start Compute
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
|
|
179
|
+
// Let's have 5 minute of compute access
|
|
180
|
+
const mytime = new Date()
|
|
181
|
+
const computeMinutes = 5
|
|
182
|
+
mytime.setMinutes(mytime.getMinutes() + computeMinutes)
|
|
183
|
+
|
|
184
|
+
// Let's prepare the dataset and algorithm assets to be used in the compute job
|
|
185
|
+
const assets: ComputeAsset[] = [
|
|
186
|
+
{
|
|
187
|
+
documentId: resolvedDatasetDdo.id,
|
|
188
|
+
serviceId: resolvedDatasetDdo.services[0].id
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
|
|
192
|
+
const algo: ComputeAlgorithm = {
|
|
193
|
+
documentId: resolvedAlgorithmDdo.id,
|
|
194
|
+
serviceId: resolvedAlgorithmDdo.services[0].id,
|
|
195
|
+
meta: resolvedAlgorithmDdo.metadata.algorithm
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Let's start the free compute job
|
|
199
|
+
const computeJobs = await ProviderInstance.freeComputeStart(
|
|
200
|
+
providerUrl,
|
|
201
|
+
consumerAccount,
|
|
202
|
+
computeEnv.id,
|
|
203
|
+
assets,
|
|
204
|
+
algo
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Paid Start Compute
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
```javascript
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
const mytime = new Date()
|
|
216
|
+
const computeMinutes = 5
|
|
217
|
+
mytime.setMinutes(mytime.getMinutes() + computeMinutes)
|
|
218
|
+
const computeValidUntil = Math.floor(mytime.getTime() / 1000)
|
|
219
|
+
|
|
220
|
+
const resources: ComputeResourceRequest[] = [
|
|
221
|
+
{
|
|
222
|
+
id: 'cpu',
|
|
223
|
+
amount: 2
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
id: 'ram',
|
|
227
|
+
amount: 2
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
id: 'disk',
|
|
231
|
+
amount: 0
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
const assets: ComputeAsset[] = [
|
|
235
|
+
{
|
|
236
|
+
documentId: resolvedDatasetDdo.id,
|
|
237
|
+
serviceId: resolvedDatasetDdo.services[0].id
|
|
238
|
+
}
|
|
239
|
+
]
|
|
240
|
+
const dtAddressArray = [resolvedDatasetDdo.services[0].datatokenAddress]
|
|
241
|
+
const algo: ComputeAlgorithm = {
|
|
242
|
+
documentId: resolvedAlgorithmDdo.id,
|
|
243
|
+
serviceId: resolvedAlgorithmDdo.services[0].id,
|
|
244
|
+
meta: resolvedAlgorithmDdo.metadata.algorithm
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const providerInitializeComputeResults = await ProviderInstance.initializeCompute(
|
|
248
|
+
assets,
|
|
249
|
+
algo,
|
|
250
|
+
computeEnv.id,
|
|
251
|
+
paymentToken,
|
|
252
|
+
computeValidUntil,
|
|
253
|
+
providerUrl,
|
|
254
|
+
consumerAccount,
|
|
255
|
+
resources,
|
|
256
|
+
Number(chainId)
|
|
257
|
+
)
|
|
258
|
+
// Initialize payment contract
|
|
259
|
+
const escrow = new EscrowContract(
|
|
260
|
+
getAddress(providerInitializeComputeResults.payment.escrowAddress),
|
|
261
|
+
consumerAccount
|
|
262
|
+
)
|
|
263
|
+
const amountToDeposit = (providerInitializeComputeResults.payment.amount * 2).toString()
|
|
264
|
+
await escrow.verifyFundsForEscrowPayment(
|
|
265
|
+
paymentToken,
|
|
266
|
+
computeEnv.consumerAddress,
|
|
267
|
+
await unitsToAmount(consumerAccount, paymentToken, amountToDeposit),
|
|
268
|
+
providerInitializeComputeResults.payment.amount.toString(),
|
|
269
|
+
providerInitializeComputeResults.payment.minLockSeconds.toString(),
|
|
270
|
+
'10'
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
algo.transferTxId = await handleOrder(
|
|
274
|
+
providerInitializeComputeResults.algorithm,
|
|
275
|
+
resolvedAlgorithmDdo.services[0].datatokenAddress,
|
|
276
|
+
consumerAccount,
|
|
277
|
+
computeEnv.consumerAddress,
|
|
278
|
+
0
|
|
279
|
+
)
|
|
280
|
+
for (let i = 0; i < providerInitializeComputeResults.datasets.length; i++) {
|
|
281
|
+
assets[i].transferTxId = await handleOrder(
|
|
282
|
+
providerInitializeComputeResults.datasets[i],
|
|
283
|
+
dtAddressArray[i],
|
|
284
|
+
consumerAccount,
|
|
285
|
+
computeEnv.consumerAddress,
|
|
286
|
+
0
|
|
287
|
+
)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const computeJobs = await ProviderInstance.computeStart(
|
|
291
|
+
providerUrl,
|
|
292
|
+
consumerAccount,
|
|
293
|
+
computeEnv.id,
|
|
294
|
+
assets,
|
|
295
|
+
algo,
|
|
296
|
+
computeValidUntil,
|
|
297
|
+
paymentToken,
|
|
298
|
+
resources,
|
|
299
|
+
Number(chainId)
|
|
300
|
+
)
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Get compute job status
|
|
304
|
+
|
|
305
|
+
```javascript
|
|
306
|
+
|
|
307
|
+
const jobStatus = await ProviderInstance.computeStatus(
|
|
308
|
+
providerUrl,
|
|
309
|
+
await consumerAccount.getAddress(),
|
|
310
|
+
computeJobId
|
|
311
|
+
)
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Get download compute results URL
|
|
315
|
+
|
|
316
|
+
```javascript
|
|
317
|
+
|
|
318
|
+
const downloadURL = await ProviderInstance.getComputeResultUrl(
|
|
319
|
+
providerUrl,
|
|
320
|
+
consumerAccount,
|
|
321
|
+
computeJobId,
|
|
322
|
+
0
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
```
|
package/CodeExamples.md
CHANGED
|
@@ -45,7 +45,7 @@ We start by initializing the services. To do this, we clone the Barge repository
|
|
|
45
45
|
```bash
|
|
46
46
|
git clone https://github.com/oceanprotocol/barge.git
|
|
47
47
|
cd barge/
|
|
48
|
-
./start_ocean.sh
|
|
48
|
+
./start_ocean.sh
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
## 2. Create a new node.js project
|
|
@@ -66,7 +66,7 @@ cat > marketplace.js
|
|
|
66
66
|
Install dependencies running the following command in your terminal:
|
|
67
67
|
|
|
68
68
|
```bash
|
|
69
|
-
npm install @oceanprotocol/lib crypto-js ethers
|
|
69
|
+
npm install @oceanprotocol/lib crypto-js ethers
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
## 4. Import dependencies and add variables and constants
|
package/ComputeExamples.md
CHANGED
|
@@ -35,7 +35,7 @@ We start by initializing the services. To do this, we clone the Barge repository
|
|
|
35
35
|
```bash
|
|
36
36
|
git clone https://github.com/oceanprotocol/barge.git
|
|
37
37
|
cd barge/
|
|
38
|
-
./start_ocean.sh
|
|
38
|
+
./start_ocean.sh
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
## 2. Create a new Node.js project with TypeScript
|
|
@@ -106,7 +106,7 @@ node dist/compute.js
|
|
|
106
106
|
Install dependencies running the following command in your terminal:
|
|
107
107
|
|
|
108
108
|
```bash
|
|
109
|
-
npm install @oceanprotocol/lib crypto-js ethers
|
|
109
|
+
npm install @oceanprotocol/lib crypto-js ethers
|
|
110
110
|
```
|
|
111
111
|
|
|
112
112
|
## 4. Import dependencies and add variables, constants and helper methods
|
|
@@ -792,7 +792,7 @@ let's select compute environment which have free and paid resources
|
|
|
792
792
|
},
|
|
793
793
|
{
|
|
794
794
|
id: 'ram',
|
|
795
|
-
amount:
|
|
795
|
+
amount: 2
|
|
796
796
|
},
|
|
797
797
|
{
|
|
798
798
|
id: 'disk',
|
package/README.md
CHANGED
|
@@ -13,9 +13,11 @@
|
|
|
13
13
|
|
|
14
14
|
With ocean.js, you can:
|
|
15
15
|
|
|
16
|
-
- **Publish** data services: downloadable files or compute-to-data. Create an ERC721 **data NFT** for each service, and ERC20 **datatoken** for access (1.0 datatokens to access).
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
16
|
+
- **Publish** data services: downloadable files or compute-to-data (C2D). Create an ERC721 **data NFT** for each service, and ERC20 **datatoken** for access (1.0 datatokens to access).
|
|
17
|
+
- **Consume** data: download files or run compute-to-data jobs on datasets while preserving data privacy.
|
|
18
|
+
- **Sell** datatokens via fixed-rate exchanges or dispense them for free.
|
|
19
|
+
- **Manage pricing**: create fixed-rate exchanges, dispensers, or use dynamic pricing mechanisms for your assets.
|
|
20
|
+
- **Compute-to-Data**: run algorithms on the ocean network.
|
|
19
21
|
|
|
20
22
|
ocean.js is part of the [Ocean Protocol](https://oceanprotocol.com) toolset.
|
|
21
23
|
|
|
@@ -23,6 +25,7 @@ This is in alpha state. If you run into problems, please open up a [new issue](h
|
|
|
23
25
|
|
|
24
26
|
- [📚 Prerequisites](#-prerequisites)
|
|
25
27
|
- [🏗 Installation & Usage](#-installation--usage)
|
|
28
|
+
- [📖 Documentation](#-documentation)
|
|
26
29
|
- [🦑 Development](#-development)
|
|
27
30
|
- [✨ Code Style](#-code-style)
|
|
28
31
|
- [👩🔬 Testing](#-testing)
|
|
@@ -46,7 +49,7 @@ This is in alpha state. If you run into problems, please open up a [new issue](h
|
|
|
46
49
|
npm install @oceanprotocol/lib
|
|
47
50
|
```
|
|
48
51
|
|
|
49
|
-
- Checkout our [code examples](CodeExamples.md)
|
|
52
|
+
- Checkout our [code examples](CodeExamples.md), [compute-to-data examples](ComputeExamples.md), or [quick reference cheatsheet](Cheatsheet.md) to see how you can use ocean.js.
|
|
50
53
|
- Refer to the [Ocean Protocol documentation](https://docs.oceanprotocol.com/) for more guides and tutorials.
|
|
51
54
|
- Visit the [Ocean Protocol website](https://docs.oceanprotocol.com/) for general information about Ocean Protocol.
|
|
52
55
|
- If you have any difficulties or if you have further questions about how to use ocean.js please reach out to us on [Discord](https://discord.gg/TnXjkR5).
|
|
@@ -61,6 +64,29 @@ npm install @oceanprotocol/lib
|
|
|
61
64
|
```
|
|
62
65
|
- If using Next.js, they may need "moduleResolution": "bundler" for better compatibility.
|
|
63
66
|
|
|
67
|
+
## 📖 Documentation
|
|
68
|
+
|
|
69
|
+
### Quick Start Guides
|
|
70
|
+
|
|
71
|
+
- **[Code Examples](CodeExamples.md)**: Complete walkthrough of publishing and consuming datasets
|
|
72
|
+
- Creating Data NFTs and Datatokens
|
|
73
|
+
- Setting up fixed-rate exchanges and dispensers
|
|
74
|
+
- Buying and consuming data assets
|
|
75
|
+
- Using ERC725 key-value store
|
|
76
|
+
|
|
77
|
+
- **[Compute-to-Data Examples](ComputeExamples.md)**: Comprehensive guide to C2D features
|
|
78
|
+
- Publishing datasets and algorithms for compute
|
|
79
|
+
- Starting free compute jobs
|
|
80
|
+
- Running paid compute jobs with custom resources
|
|
81
|
+
- Checking compute status and retrieving results
|
|
82
|
+
|
|
83
|
+
- **[Cheatsheet](Cheatsheet.md)**: Quick reference for common operations
|
|
84
|
+
- Publishing datasets
|
|
85
|
+
- Consuming data
|
|
86
|
+
- Free and paid compute workflows
|
|
87
|
+
- Getting compute job status
|
|
88
|
+
|
|
89
|
+
|
|
64
90
|
## 🦑 Development
|
|
65
91
|
|
|
66
92
|
The project is authored with TypeScript and compiled with `tsc`.
|
|
@@ -88,13 +114,13 @@ npm run format
|
|
|
88
114
|
|
|
89
115
|
Test suite for unit & integration tests is setup with [Mocha](https://mochajs.org) as test runner, and [nyc](https://github.com/istanbuljs/nyc) for coverage reporting. A combined coverage report is sent to CodeClimate via the `coverage` GitHub Actions job.
|
|
90
116
|
|
|
91
|
-
Running all tests requires running Ocean Protocol components beforehand with [Barge](https://github.com/oceanprotocol/barge), which also runs a
|
|
117
|
+
Running all tests requires running Ocean Protocol components beforehand with [Barge](https://github.com/oceanprotocol/barge), which also runs a local blockchain instance:
|
|
92
118
|
|
|
93
119
|
```bash
|
|
94
120
|
git clone https://github.com/oceanprotocol/barge
|
|
95
121
|
cd barge
|
|
96
122
|
|
|
97
|
-
./start_ocean.sh
|
|
123
|
+
./start_ocean.sh
|
|
98
124
|
```
|
|
99
125
|
|
|
100
126
|
You can then proceed to run in another terminal.
|
|
@@ -199,7 +225,7 @@ Further releases afterwards can be done with `npm run release` again and selecti
|
|
|
199
225
|
## 🏛 License
|
|
200
226
|
|
|
201
227
|
```
|
|
202
|
-
Copyright ((C))
|
|
228
|
+
Copyright ((C)) 2025 Ocean Protocol Foundation
|
|
203
229
|
|
|
204
230
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
205
231
|
you may not use this file except in compliance with the License.
|