diff --git a/Cheatsheet.md b/Cheatsheet.md index 2be93cbb5..8784a0905 100644 --- a/Cheatsheet.md +++ b/Cheatsheet.md @@ -10,7 +10,7 @@ ```bash npm init -npm install @oceanprotocol/lib crypto-js ethers@5.7.2 typescript @types/node ts-node +npm install @oceanprotocol/lib crypto-js ethers typescript @types/node ts-node ``` ### Configuration @@ -224,7 +224,7 @@ const resources: ComputeResourceRequest[] = [ }, { id: 'ram', - amount: 1000000000 + amount: 2 }, { id: 'disk', diff --git a/CodeExamples.md b/CodeExamples.md index 7e9f7d306..92a95c929 100644 --- a/CodeExamples.md +++ b/CodeExamples.md @@ -45,7 +45,7 @@ We start by initializing the services. To do this, we clone the Barge repository ```bash git clone https://github.com/oceanprotocol/barge.git cd barge/ -./start_ocean.sh --with-provider2 --no-dashboard +./start_ocean.sh ``` ## 2. Create a new node.js project diff --git a/ComputeExamples.md b/ComputeExamples.md index ac2e0004e..d3477c509 100644 --- a/ComputeExamples.md +++ b/ComputeExamples.md @@ -35,7 +35,7 @@ We start by initializing the services. To do this, we clone the Barge repository ```bash git clone https://github.com/oceanprotocol/barge.git cd barge/ -./start_ocean.sh --with-provider2 --no-dashboard --with-c2d +./start_ocean.sh ``` ## 2. Create a new Node.js project with TypeScript diff --git a/README.md b/README.md index 60998ae15..50bfa708e 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,11 @@ With ocean.js, you can: -- **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). -- **Sell** datatokens for a fixed price. Sell data NFTs. -- **Transfer** data NFTs & datatokens to another owner, and **all other ERC721 & ERC20 actions** using [web3.js](https://web3js.readthedocs.io/en/v1.2.9/web3-eth-contract.html) etc. +- **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). +- **Consume** data: download files or run compute-to-data jobs on datasets while preserving data privacy. +- **Sell** datatokens via fixed-rate exchanges or dispense them for free. +- **Manage pricing**: create fixed-rate exchanges, dispensers, or use dynamic pricing mechanisms for your assets. +- **Compute-to-Data**: run algorithms on the ocean network. ocean.js is part of the [Ocean Protocol](https://oceanprotocol.com) toolset. @@ -23,6 +25,7 @@ This is in alpha state. If you run into problems, please open up a [new issue](h - [📚 Prerequisites](#-prerequisites) - [🏗 Installation & Usage](#-installation--usage) +- [📖 Documentation](#-documentation) - [🦑 Development](#-development) - [✨ Code Style](#-code-style) - [👩‍🔬 Testing](#-testing) @@ -46,7 +49,7 @@ This is in alpha state. If you run into problems, please open up a [new issue](h npm install @oceanprotocol/lib ``` -- Checkout our [code examples](CodeExamples.md) or [compute to data examples](C2DExamples.md) to see how you can use ocean.js. +- 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. - Refer to the [Ocean Protocol documentation](https://docs.oceanprotocol.com/) for more guides and tutorials. - Visit the [Ocean Protocol website](https://docs.oceanprotocol.com/) for general information about Ocean Protocol. - 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 ``` - If using Next.js, they may need "moduleResolution": "bundler" for better compatibility. +## 📖 Documentation + +### Quick Start Guides + +- **[Code Examples](CodeExamples.md)**: Complete walkthrough of publishing and consuming datasets + - Creating Data NFTs and Datatokens + - Setting up fixed-rate exchanges and dispensers + - Buying and consuming data assets + - Using ERC725 key-value store + +- **[Compute-to-Data Examples](ComputeExamples.md)**: Comprehensive guide to C2D features + - Publishing datasets and algorithms for compute + - Starting free compute jobs + - Running paid compute jobs with custom resources + - Checking compute status and retrieving results + +- **[Cheatsheet](Cheatsheet.md)**: Quick reference for common operations + - Publishing datasets + - Consuming data + - Free and paid compute workflows + - Getting compute job status + + ## 🦑 Development The project is authored with TypeScript and compiled with `tsc`. @@ -88,13 +114,13 @@ npm run format 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. -Running all tests requires running Ocean Protocol components beforehand with [Barge](https://github.com/oceanprotocol/barge), which also runs a `ganache-cli` instance: +Running all tests requires running Ocean Protocol components beforehand with [Barge](https://github.com/oceanprotocol/barge), which also runs a local blockchain instance: ```bash git clone https://github.com/oceanprotocol/barge cd barge -./start_ocean.sh --with-provider2 --no-dashboard --with-c2d +./start_ocean.sh ``` 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 ## 🏛 License ``` -Copyright ((C)) 2023 Ocean Protocol Foundation +Copyright ((C)) 2025 Ocean Protocol Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/docs/README.md b/docs/README.md index b4249b76f..7a4df3669 100644 --- a/docs/README.md +++ b/docs/README.md @@ -15,9 +15,12 @@ With ocean.js, you can: -- **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). -- **Sell** datatokens for a fixed price. Sell data NFTs. -- **Transfer** data NFTs & datatokens to another owner, and **all other ERC721 & ERC20 actions** using [web3.js](https://web3js.readthedocs.io/en/v1.2.9/web3-eth-contract.html) etc. +- **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). +- **Consume** data: download files or run compute-to-data jobs on datasets while preserving data privacy. +- **Sell** datatokens via fixed-rate exchanges or dispense them for free. +- **Manage pricing**: create fixed-rate exchanges, dispensers, or use dynamic pricing mechanisms for your assets. +- **Compute-to-Data**: run algorithms on the ocean network. +- **Transfer** data NFTs & datatokens to another owner, and **all other ERC721 & ERC20 actions** using ethers.js. ocean.js is part of the [Ocean Protocol](https://oceanprotocol.com) toolset. @@ -48,7 +51,7 @@ This is in alpha state. If you run into problems, please open up a [new issue](h npm install @oceanprotocol/lib ``` -- Checkout our [code examples](CodeExamples.md) or [compute to data examples](C2DExamples.md) to see how you can use ocean.js. +- 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. - Refer to the [Ocean Protocol documentation](https://docs.oceanprotocol.com/) for more guides and tutorials. - Visit the [Ocean Protocol website](https://docs.oceanprotocol.com/) for general information about Ocean Protocol. - 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). @@ -81,13 +84,13 @@ npm run format 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. -Running all tests requires running Ocean Protocol components beforehand with [Barge](https://github.com/oceanprotocol/barge), which also runs a `ganache-cli` instance: +Running all tests requires running Ocean Protocol components beforehand with [Barge](https://github.com/oceanprotocol/barge), which also runs a local blockchain instance: ```bash git clone https://github.com/oceanprotocol/barge cd barge -./start_ocean.sh --with-provider2 --no-dashboard --with-c2d +./start_ocean.sh ``` You can then proceed to run in another terminal. @@ -176,7 +179,7 @@ Further releases afterwards can be done with `npm run release` again and selecti ## 🏛 License ``` -Copyright ((C)) 2023 Ocean Protocol Foundation +Copyright ((C)) 2025 Ocean Protocol Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/docs/classes/Escrow.md b/docs/classes/Escrow.md new file mode 100644 index 000000000..49060cf90 --- /dev/null +++ b/docs/classes/Escrow.md @@ -0,0 +1,285 @@ +[@oceanprotocol/lib](../README.md) / [Exports](../modules.md) / EscrowContract + +# Class: EscrowContract + +Manages escrow payments for C2D jobs - handles deposits, locks, and authorizations. + +## Hierarchy + +- [`SmartContractWithAddress`](SmartContractWithAddress.md) + + ↳ **`EscrowContract`** + +## Table of contents + +### Constructors + +- [constructor](Escrow.md#constructor) + +### Methods + +- [getFunds](Escrow.md#getfunds) +- [getUserFunds](Escrow.md#getuserfunds) +- [getUserTokens](Escrow.md#getusertokens) +- [getLocks](Escrow.md#getlocks) +- [getAuthorizations](Escrow.md#getauthorizations) +- [verifyFundsForEscrowPayment](Escrow.md#verifyfundsforescrowpayment) +- [deposit](Escrow.md#deposit) +- [withdraw](Escrow.md#withdraw) +- [authorize](Escrow.md#authorize) + +## Constructors + +### constructor + +• **new EscrowContract**(`address`, `signer`, `network?`, `config?`, `abi?`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `address` | `string` | +| `signer` | `Signer` | +| `network?` | `string` \| `number` | +| `config?` | [`Config`](Config.md) | +| `abi?` | [`AbiItem`](../interfaces/AbiItem.md)[] | + +#### Inherited from + +[SmartContractWithAddress](SmartContractWithAddress.md).[constructor](SmartContractWithAddress.md#constructor) + +#### Defined in + +[contracts/Escrow.ts:26](https://github.com/oceanprotocol/ocean.js/blob/main/src/contracts/Escrow.ts#L26) + +## Methods + +### getFunds + +▸ **getFunds**(`token`): `Promise`<`{available: bigint, locked: bigint}`\> + +Get total funds in escrow for a token + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `token` | `string` | token address | + +#### Returns + +`Promise`<`{available: bigint, locked: bigint}`\> + +Object with `available` and `locked` amounts + +#### Defined in + +[contracts/Escrow.ts:41](https://github.com/oceanprotocol/ocean.js/blob/main/src/contracts/Escrow.ts#L41) + +___ + +### getUserFunds + +▸ **getUserFunds**(`payer`, `token`): `Promise`<`{available: bigint, locked: bigint}`\> + +Get user's available escrow balance + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `payer` | `string` | user address | +| `token` | `string` | token address | + +#### Returns + +`Promise`<`{available: bigint, locked: bigint}`\> + +Object with `available` and `locked` amounts for this user/token pair + +#### Defined in + +[contracts/Escrow.ts:49](https://github.com/oceanprotocol/ocean.js/blob/main/src/contracts/Escrow.ts#L49) + +___ + +### getUserTokens + +▸ **getUserTokens**(`payer`): `Promise`<`string[]`\> + +Get list of tokens user has deposited + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `payer` | `string` | user address | + +#### Returns + +`Promise`<`string[]`\> + +Array of token addresses this user has deposited + +#### Defined in + +[contracts/Escrow.ts:57](https://github.com/oceanprotocol/ocean.js/blob/main/src/contracts/Escrow.ts#L57) + +___ + +### getLocks + +▸ **getLocks**(`token`, `payer`, `payee`): `Promise`<`Lock[]`\> + +Get active payment locks + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `token` | `string` | token address | +| `payer` | `string` | payer address | +| `payee` | `string` | payee address | + +#### Returns + +`Promise`<`Lock[]`\> + +Array of locks where each lock contains: `{jobId, payer, payee, amount, expiry, token}` + +#### Defined in + +[contracts/Escrow.ts:65](https://github.com/oceanprotocol/ocean.js/blob/main/src/contracts/Escrow.ts#L65) + +___ + +### getAuthorizations + +▸ **getAuthorizations**(`token`, `payer`, `payee`): `Promise`<`Authorization[]`\> + +Get payment authorizations + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `token` | `string` | token address | +| `payer` | `string` | payer address | +| `payee` | `string` | payee address | + +#### Returns + +`Promise`<`Authorization[]`\> + +Array of authorizations where each contains: `{payee, maxLockedAmount, currentLockedAmount, maxLockSeconds, maxLockCounts, currentLocks}` + +#### Defined in + +[contracts/Escrow.ts:73](https://github.com/oceanprotocol/ocean.js/blob/main/src/contracts/Escrow.ts#L73) + +___ + +### verifyFundsForEscrowPayment + +▸ **verifyFundsForEscrowPayment**(`token`, `consumerAddress`, `amountToDeposit?`, `maxLockedAmount?`, `maxLockSeconds?`, `maxLockCounts?`): `Promise`<`ValidationResponse`\> + +Checks if you have enough funds, authorizes and deposits if needed - all in one call + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `token` | `string` | payment token | +| `consumerAddress` | `string` | compute environment consumer address | +| `amountToDeposit?` | `string` | how much to deposit (optional) | +| `maxLockedAmount?` | `string` | max amount for compute job | +| `maxLockSeconds?` | `string` | max lock duration | +| `maxLockCounts?` | `string` | max number of locks | + +#### Returns + +`Promise`<`ValidationResponse`\> + +validation status + +#### Defined in + +[contracts/Escrow.ts:98](https://github.com/oceanprotocol/ocean.js/blob/main/src/contracts/Escrow.ts#L98) + +___ + +### deposit + +▸ **deposit**<`G`\>(`token`, `amount`, `estimateGas?`): `Promise`<`ReceiptOrEstimate`<`G`\>\> + +Deposit tokens into escrow + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `token` | `string` | +| `amount` | `string` | +| `estimateGas?` | `G` | + +#### Returns + +`Promise`<`ReceiptOrEstimate`<`G`\>\> + +#### Defined in + +[contracts/Escrow.ts:191](https://github.com/oceanprotocol/ocean.js/blob/main/src/contracts/Escrow.ts#L191) + +___ + +### withdraw + +▸ **withdraw**<`G`\>(`tokens`, `amounts`, `estimateGas?`): `Promise`<`ReceiptOrEstimate`<`G`\>\> + +Withdraw tokens from escrow + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `tokens` | `string[]` | array of token addresses | +| `amounts` | `string[]` | array of amounts to withdraw | +| `estimateGas?` | `G` | - | + +#### Returns + +`Promise`<`ReceiptOrEstimate`<`G`\>\> + +#### Defined in + +[contracts/Escrow.ts:217](https://github.com/oceanprotocol/ocean.js/blob/main/src/contracts/Escrow.ts#L217) + +___ + +### authorize + +▸ **authorize**<`G`\>(`token`, `payee`, `maxLockedAmount`, `maxLockSeconds`, `maxLockCounts`, `estimateGas?`): `Promise`<`ReceiptOrEstimate`<`G`\>\> + +Authorize someone to lock your funds + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `token` | `string` | +| `payee` | `string` | +| `maxLockedAmount` | `string` | +| `maxLockSeconds` | `string` | +| `maxLockCounts` | `string` | +| `estimateGas?` | `G` | + +#### Returns + +`Promise`<`ReceiptOrEstimate`<`G`\>\> + +#### Defined in + +[contracts/Escrow.ts:274](https://github.com/oceanprotocol/ocean.js/blob/main/src/contracts/Escrow.ts#L274) + +___ + diff --git a/docs/classes/Provider.md b/docs/classes/Provider.md index 4b26ceeda..11a1c040a 100644 --- a/docs/classes/Provider.md +++ b/docs/classes/Provider.md @@ -15,6 +15,8 @@ - [computeStart](Provider.md#computestart) - [computeStatus](Provider.md#computestatus) - [computeStop](Provider.md#computestop) +- [freeComputeStart](Provider.md#freecomputestart) +- [getComputeStartRoutes](Provider.md#getcomputestartroutes) - [encrypt](Provider.md#encrypt) - [getComputeEnvironments](Provider.md#getcomputeenvironments) - [getComputeResultUrl](Provider.md#getcomputeresulturl) @@ -97,24 +99,28 @@ ___ ### computeStart -▸ **computeStart**(`providerUri`, `signer`, `computeEnv`, `datasets`, `algorithm`, `resources`, `chainId`, `output?`, `freeEnvironment`, `signal?`): `Promise`<[`ComputeJob`](../interfaces/ComputeJob.md) \| [`ComputeJob`](../interfaces/ComputeJob.md)[]\> +▸ **computeStart**(`providerUri`, `signerOrAuthToken`, `computeEnv`, `datasets`, `algorithm`, `maxJobDuration`, `token`, `resources`, `chainId`, `metadata?`, `additionalViewers?`, `output?`, `policyServer?`, `signal?`): `Promise`<[`ComputeJob`](../interfaces/ComputeJob.md) \| [`ComputeJob`](../interfaces/ComputeJob.md)[]\> -Instruct the provider to start a compute job +Instruct the provider to start a PAID compute job (C2D V2) #### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `providerUri` | `string` | The provider URI. | -| `signer` | `Signer` | - | The consumer signer/account -| `computeEnv` | `string` | The compute environment. | -| `datasets` | [`ComputeAsset`](../interfaces/ComputeAsset.md) | The dataset to start compute on | +| `signerOrAuthToken` | `Signer` \| `string` | The consumer signer object or auth token | +| `computeEnv` | `string` | The compute environment ID. | +| `datasets` | [`ComputeAsset`](../interfaces/ComputeAsset.md)[] | The datasets to start compute on (including additional datasets) | | `algorithm` | [`ComputeAlgorithm`](../interfaces/ComputeAlgorithm.md) | The algorithm to start compute with. | -| `resources` | [`ComputeResourceRequest`](../interfaces/ComputeResourcesRequest.md) | The resources to start compute with. | -| `chainId?` | [`number`] | The network for the payments | +| `maxJobDuration` | `number` | The compute job max execution time. | +| `token` | `string` | The token address for compute payment. | +| `resources` | [`ComputeResourceRequest`](../interfaces/ComputeResourcesRequest.md)[] | The resources to start compute job with. | +| `chainId` | `number` | The chain ID used for payments | +| `metadata?` | `ComputeJobMetadata` | Additional metadata to be stored in the database. | +| `additionalViewers?` | `string[]` | Additional addresses that can view the compute job results. | | `output?` | [`ComputeOutput`](../interfaces/ComputeOutput.md) | The compute job output settings. | -| `signal?` | `AbortSignal` | abort signal | - +| `policyServer?` | `any` | Policy server data. | +| `signal?` | `AbortSignal` | Abort signal | #### Returns @@ -124,7 +130,7 @@ The compute job or jobs. #### Defined in -[services/Provider.ts:516](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/services/Provider.ts#L516) +[services/Provider.ts:772](https://github.com/oceanprotocol/ocean.js/blob/main/src/services/Provider.ts#L772) ___ @@ -182,6 +188,65 @@ Instruct the provider to Stop the execution of a to stop a compute job. ___ +### freeComputeStart + +▸ **freeComputeStart**(`providerUri`, `signerOrAuthToken`, `computeEnv`, `datasets`, `algorithm`, `resources?`, `metadata?`, `additionalViewers?`, `output?`, `policyServer?`, `signal?`): `Promise`<[`ComputeJob`](../interfaces/ComputeJob.md) \| [`ComputeJob`](../interfaces/ComputeJob.md)[]\> + +Instruct the provider to start a FREE compute job (C2D V2) + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `providerUri` | `string` | The provider URI. | +| `signerOrAuthToken` | `Signer` \| `string` | The consumer signer object or auth token | +| `computeEnv` | `string` | The compute environment ID. | +| `datasets` | [`ComputeAsset`](../interfaces/ComputeAsset.md)[] | The datasets to start compute on (including additional datasets) | +| `algorithm` | [`ComputeAlgorithm`](../interfaces/ComputeAlgorithm.md) | The algorithm to start compute with. | +| `resources?` | [`ComputeResourceRequest`](../interfaces/ComputeResourcesRequest.md)[] | The resources to start compute job with. | +| `metadata?` | `ComputeJobMetadata` | Additional metadata to be stored in the database. | +| `additionalViewers?` | `string[]` | Additional addresses that can view the compute job results. | +| `output?` | [`ComputeOutput`](../interfaces/ComputeOutput.md) | The compute job output settings. | +| `policyServer?` | `any` | Policy server data. | +| `signal?` | `AbortSignal` | Abort signal | + +#### Returns + +`Promise`<[`ComputeJob`](../interfaces/ComputeJob.md) \| [`ComputeJob`](../interfaces/ComputeJob.md)[]\> + +The compute job or jobs. + +#### Defined in + +[services/Provider.ts:892](https://github.com/oceanprotocol/ocean.js/blob/main/src/services/Provider.ts#L892) + +___ + +### getComputeStartRoutes + +▸ **getComputeStartRoutes**(`providerUri`, `isFreeCompute?`): `Promise`<`string` \| `null`\> + +Get the compute start route path for either free or paid compute + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `providerUri` | `string` | `undefined` | The provider URI. | +| `isFreeCompute` | `boolean` | `false` | Whether to get the free compute route (true) or paid compute route (false). | + +#### Returns + +`Promise`<`string` \| `null`\> + +The compute start route path or null if not available. + +#### Defined in + +[services/Provider.ts:1071](https://github.com/oceanprotocol/ocean.js/blob/main/src/services/Provider.ts#L1071) + +___ + ### encrypt ▸ **encrypt**(`data`, `chainId`, `providerUri`, `signal?`): `Promise`<`string`\> diff --git a/docs/interfaces/ComputeEnvironment.md b/docs/interfaces/ComputeEnvironment.md index a43ac78a0..2c08f55d6 100644 --- a/docs/interfaces/ComputeEnvironment.md +++ b/docs/interfaces/ComputeEnvironment.md @@ -6,62 +6,31 @@ ### Properties -- [consumerAddress](ComputeEnvironment.md#consumeraddress) -- [totalCpu](ComputeEnvironment.md#totalCpu) -- [maxCpu](ComputeEnvironment.md#maxCpu) -- [totalRam](ComputeEnvironment.md#totalRam) -- [maxRam](ComputeEnvironment.md#maxRam) -- [maxDisk](ComputeEnvironment.md#maxDisk) -- [currentJobs](ComputeEnvironment.md#currentjobs) -- [description](ComputeEnvironment.md#description) -- [fees](ComputeEnvironment.md#ComputeEnvFeesStructure) - [id](ComputeEnvironment.md#id) -- [lastSeen](ComputeEnvironment.md#lastseen) +- [description](ComputeEnvironment.md#description) +- [consumerAddress](ComputeEnvironment.md#consumeraddress) +- [storageExpiry](ComputeEnvironment.md#storageexpiry) +- [minJobDuration](ComputeEnvironment.md#minjobduration) - [maxJobDuration](ComputeEnvironment.md#maxjobduration) - [maxJobs](ComputeEnvironment.md#maxjobs) -- [storageExpiry](ComputeEnvironment.md#storageexpiry) -- [lastSeen](ComputeEnvironment.md#lastSeen) +- [runningJobs](ComputeEnvironment.md#runningjobs) +- [runningfreeJobs](ComputeEnvironment.md#runningfreejobs) +- [fees](ComputeEnvironment.md#fees) +- [resources](ComputeEnvironment.md#resources) - [free](ComputeEnvironment.md#free) +- [platform](ComputeEnvironment.md#platform) ## Properties -### consumerAddress - -• **consumerAddress**: `string` - -#### Defined in - -[@types/Compute.ts:68](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L68) - -___ - -### totalCpu - -• **totalCpu**: `number` - -#### Defined in - -[@types/Compute.ts:58](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L58) - -___ - -### maxCpu - -• **maxCpu**: `number` - -#### Defined in - -[@types/Compute.ts:59](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L59) - -___ +### id -### currentJobs +• **id**: `string` -• **currentJobs**: `number` +Unique identifier for the compute environment #### Defined in -[@types/Compute.ts:66](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L66) +[@types/Compute.ts:88](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L88) ___ @@ -69,79 +38,95 @@ ___ • **description**: `string` +Description of the compute environment + #### Defined in -[@types/Compute.ts:65](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L65) +[@types/Compute.ts:89](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L89) ___ -### maxDisk +### consumerAddress + +• **consumerAddress**: `string` -• **maxDisk**: `number` +Consumer address for the compute environment #### Defined in -[@types/Compute.ts:62](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L62) +[@types/Compute.ts:90](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L90) ___ -### maxRam +### storageExpiry + +• `Optional` **storageExpiry**: `number` -• **maxRam**: `number` +Amount of seconds for storage #### Defined in -[@types/Compute.ts:61](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L61) +[@types/Compute.ts:91](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L91) ___ -### totalRam +### minJobDuration -• **totalRam**: `number` +• `Optional` **minJobDuration**: `number` + +Minimum billable seconds for a paid job #### Defined in -[@types/Compute.ts:60](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L60) +[@types/Compute.ts:92](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L92) ___ -### id +### maxJobDuration -• **id**: `string` +• `Optional` **maxJobDuration**: `number` + +Maximum duration in seconds for a paid job #### Defined in -[@types/Compute.ts:49](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L49) +[@types/Compute.ts:93](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L93) ___ -### lastSeen +### maxJobs + +• `Optional` **maxJobs**: `number` -• **lastSeen**: `number` +Maximum number of simultaneous paid jobs #### Defined in -[@types/Compute.ts:71](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L71) +[@types/Compute.ts:94](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L94) ___ -### maxJobDuration +### runningJobs + +• **runningJobs**: `number` -• **maxJobDuration**: `number` +Amount of running jobs (paid jobs) #### Defined in -[@types/Compute.ts:70](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L70) +[@types/Compute.ts:95](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L95) ___ -### maxJobs +### runningfreeJobs + +• `Optional` **runningfreeJobs**: `number` -• **maxJobs**: `number` +Amount of running jobs (free jobs) #### Defined in -[@types/Compute.ts:67](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L67) +[@types/Compute.ts:96](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L96) ___ @@ -149,36 +134,44 @@ ___ • **fees**: `ComputeEnvFeesStructure` +Fee structure for the compute environment + #### Defined in -[@types/Compute.ts:63](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L63) +[@types/Compute.ts:97](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L97) ___ -### free +### resources + +• `Optional` **resources**: `ComputeResource[]` -• **free**: `boolean` +Available compute resources (CPU, memory, storage) #### Defined in -[@types/Compute.ts:72](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L72) +[@types/Compute.ts:98](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L98) ___ -### storageExpiry +### free + +• `Optional` **free**: `ComputeEnvironmentFreeOptions` -• **storageExpiry**: `number` +Free compute environment options #### Defined in -[@types/Compute.ts:69](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L69) +[@types/Compute.ts:99](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L99) ___ ### platform -• **platform**: `RunningPlatform[]` +• `Optional` **platform**: `RunningPlatform` + +Platform information (architecture, OS) #### Defined in -[@types/Compute.ts:73](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L73) +[@types/Compute.ts:100](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L100) diff --git a/docs/interfaces/ComputeJob.md b/docs/interfaces/ComputeJob.md index b2112e516..e0312b6e3 100644 --- a/docs/interfaces/ComputeJob.md +++ b/docs/interfaces/ComputeJob.md @@ -18,6 +18,8 @@ - [results](ComputeJob.md#results) - [status](ComputeJob.md#status) - [statusText](ComputeJob.md#statustext) +- [metadata](ComputeJob.md#metadata) +- [terminationDetails](ComputeJob.md#terminationdetails) ## Properties @@ -137,4 +139,35 @@ ___ #### Defined in -[@types/Compute.ts:41](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L41) +[@types/Compute.ts:121](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L121) + +___ + +### metadata + +• `Optional` **metadata**: `ComputeJobMetadata` + +Custom metadata associated with the compute job + +#### Defined in + +[@types/Compute.ts:127](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L127) + +___ + +### terminationDetails + +• `Optional` **terminationDetails**: `object` + +Details about job termination + +#### Type declaration + +| Name | Type | Description | +| :------ | :------ | :------ | +| `exitCode?` | `number` | Exit code of the terminated job | +| `OOMKilled?` | `boolean` | Whether the job was killed due to out-of-memory | + +#### Defined in + +[@types/Compute.ts:128](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L128) diff --git a/docs/interfaces/ComputeResourcesRequest.md b/docs/interfaces/ComputeResourcesRequest.md index 67b7c166c..67f8ddce7 100644 --- a/docs/interfaces/ComputeResourcesRequest.md +++ b/docs/interfaces/ComputeResourcesRequest.md @@ -15,9 +15,11 @@ • **id**: `string` +Resource identifier (e.g., 'cpu', 'ram', 'disk') + #### Defined in -[@types/Compute.ts:63](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L63) +[@types/Compute.ts:50](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L50) ___ @@ -25,6 +27,8 @@ ___ • **amount**: `number` +Amount of the specified resource to request. DISK and RAM are in GB, CPU is in number of cores. + #### Defined in -[@types/Compute.ts:64](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Compute.ts#L64) +[@types/Compute.ts:51](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Compute.ts#L51) diff --git a/docs/interfaces/ProviderComputeInitializeResults.md b/docs/interfaces/ProviderComputeInitializeResults.md index 33419d26e..b2555ed59 100644 --- a/docs/interfaces/ProviderComputeInitializeResults.md +++ b/docs/interfaces/ProviderComputeInitializeResults.md @@ -8,6 +8,7 @@ - [algorithm](ProviderComputeInitializeResults.md#algorithm) - [datasets](ProviderComputeInitializeResults.md#datasets) +- [payment](ProviderComputeInitializeResults.md#payment) ## Properties @@ -27,4 +28,16 @@ ___ #### Defined in -[@types/Provider.ts:27](https://github.com/oceanprotocol/ocean.js/blob/c99bc5c6/src/@types/Provider.ts#L27) +[@types/Provider.ts:36](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Provider.ts#L36) + +___ + +### payment + +• `Optional` **payment**: `ProviderComputeInitializePayment` + +Payment information for compute initialization including escrow address, chain ID, payee, token, amount, and minimum lock seconds + +#### Defined in + +[@types/Provider.ts:37](https://github.com/oceanprotocol/ocean.js/blob/main/src/@types/Provider.ts#L37) diff --git a/test/integration/CodeExamples.test.ts b/test/integration/CodeExamples.test.ts index 4fc224609..f1eaa1589 100644 --- a/test/integration/CodeExamples.test.ts +++ b/test/integration/CodeExamples.test.ts @@ -45,7 +45,7 @@ /// ```bash /// git clone https://github.com/oceanprotocol/barge.git /// cd barge/ -/// ./start_ocean.sh --with-provider2 --no-dashboard +/// ./start_ocean.sh /// ``` /// ## 2. Create a new node.js project diff --git a/test/integration/ComputeExamples.test.ts b/test/integration/ComputeExamples.test.ts index 878aacec5..40aa4e115 100644 --- a/test/integration/ComputeExamples.test.ts +++ b/test/integration/ComputeExamples.test.ts @@ -35,7 +35,7 @@ /// ```bash /// git clone https://github.com/oceanprotocol/barge.git /// cd barge/ -/// ./start_ocean.sh --with-provider2 --no-dashboard --with-c2d +/// ./start_ocean.sh /// ``` /// ## 2. Create a new Node.js project with TypeScript