forked from iExecBlockchainComputing/iexec-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92c9bf6
commit 460192e
Showing
74 changed files
with
11,589 additions
and
3,337 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
iexec / [Exports](modules.md) | ||
|
||
[< Back home](../README.md) | ||
|
||
# iExec SDK Library API | ||
|
||
[](https://drone.iex.ec/iExecBlockchainComputing/iexec-sdk) | ||
[](https://www.npmjs.com/package/iexec) [](https://www.npmjs.com/package/iexec) [](LICENSE) | ||
|
||
Use the iExec decentralised marketplace for off-chain computing in your dapp. | ||
|
||
## Content | ||
|
||
- [Install](#install) | ||
- [Quick start](#quick-start) | ||
- [API](#api) | ||
- [IExecModules](#iexecmodules) | ||
- [utils](#utils) | ||
- [errors](#errors) | ||
- [Live demos](#live-demos) | ||
|
||
--- | ||
|
||
# Install | ||
|
||
Install iexec sdk | ||
|
||
```bash | ||
npm install iexec | ||
``` | ||
|
||
--- | ||
|
||
# Quick start | ||
|
||
## Front-end integration | ||
|
||
```js | ||
import { IExec } from 'iexec'; | ||
|
||
// connect injected provider | ||
const iexec = new IExec({ ethProvider: window.ethereum }); | ||
``` | ||
|
||
## Back-end integration | ||
|
||
```js | ||
const { IExec, utils } = require('iexec'); | ||
|
||
const { PRIVATE_KEY } = process.env; | ||
|
||
const ethProvider = utils.getSignerFromPrivateKey( | ||
'http://localhost:8545', // blockchain node URL | ||
PRIVATE_KEY, | ||
); | ||
const iexec = new IExec({ | ||
ethProvider, | ||
}); | ||
``` | ||
|
||
--- | ||
|
||
# API | ||
|
||
## IExecModules | ||
|
||
IExec SDK is splitted into [IExecModule](./classes/IExecModule.md)s, each providing a set of methods relatives to a specific field. | ||
|
||
Additionaly the [IExec](./classes/IExec.md) module exposes all the following listed modules under the corresponding namespace. | ||
|
||
- [IExecAccountModule](./classes/IExecAccountModule.md) exposes **account** methods | ||
- [IExecAppModule](./classes/IExecAppModule.md) exposes **app** methods | ||
- [IExecDatasetModule](./classes/IExecDatasetModule.md) exposes **dataset** methods | ||
- [IExecDealModule](./classes/IExecDealModule.md) exposes **deal** methods | ||
- [IExecENSModule](./classes/IExecENSModule.md) exposes **ENS** methods | ||
- [IExecHubModule](./classes/IExecHubModule.md) exposes **hub** methods | ||
- [IExecNetworkModule](./classes/IExecNetworkModule.md) exposes **network** methods | ||
- [IExecOrderModule](./classes/IExecOrderModule.md) exposes **order** methods | ||
- [IExecOrderbookModule](./classes/IExecOrderbookModule.md) exposes **orderbook** methods | ||
- [IExecResultModule](./classes/IExecResultModule.md) exposes **result** methods | ||
- [IExecStorageModule](./classes/IExecStorageModule.md) exposes **storage** methods | ||
- [IExecTaskModule](./classes/IExecTaskModule.md) exposes **task** methods | ||
- [IExecWalletModule](./classes/IExecWalletModule.md) exposes **wallet** methods | ||
- [IExecWorkerpoolModule](./classes/IExecWorkerpoolModule.md) exposes **workerpool** methods | ||
|
||
### Imports | ||
|
||
As your app won't probably use all the features, you may want to import only the modules you need. | ||
|
||
Each module is available as an independant package under `iexec/MODULE_NAME` and is exported in the umbrella package. | ||
|
||
_example:_ | ||
|
||
- import from module package | ||
|
||
```js | ||
import IExecWalletModule from 'iexec/IExecWalletModule'; | ||
``` | ||
|
||
- import from umbrella | ||
|
||
```js | ||
import { IExecWalletModule } from 'iexec'; | ||
``` | ||
|
||
### Usage | ||
|
||
[IExecModule](./classes/IExecModule.md)s are instancied with an [IExecConfig](./classes/IExecConfig.md) providing the configuration to access to a specific instance of the iExec platform. | ||
|
||
Once created, an [IExecConfig](./classes/IExecConfig.md) can be shared with any [IExecModule](./classes/IExecModule.md). | ||
|
||
_example:_ | ||
|
||
- standard usage | ||
|
||
```js | ||
import IExecConfig from 'iexec/IExecConfig'; | ||
|
||
import IExecWalletModule from 'iexec/IExecWalletModule'; | ||
import IExecAccountModule from 'iexec/IExecAccountModule'; | ||
|
||
// create the config once for the target iExec instance | ||
const config = new IExecConfig({ ethProvider: window.ethereum }); | ||
|
||
// share it with all the modules | ||
const wallet = IExecWalletModule.fromConfig(config); | ||
const account = IExecAccountModule.fromConfig(config); | ||
``` | ||
|
||
- reuse instancied module configuration | ||
|
||
```js | ||
import IExecWalletModule from 'iexec/IExecWalletModule'; | ||
// some IExecModule instance | ||
import iexecModule from './my-module'; | ||
|
||
// IExecModules expose their IExecConfig under config | ||
const wallet = IExecWalletModule.fromConfig(iexecModule.config); | ||
``` | ||
|
||
- quick instanciation (shorter but not recommanded) | ||
|
||
```js | ||
import IExecWalletModule from 'iexec/IExecWalletModule'; | ||
|
||
// the IExecConfig step can be skipped | ||
const wallet = new IExecWalletModule({ ethProvider: window.ethereum }); | ||
``` | ||
|
||
## utils | ||
|
||
The [utils](./modules/utils.md) namespace exposes some utility methods. | ||
|
||
_example_: | ||
|
||
```js | ||
import utils from 'iexec/utils'; | ||
``` | ||
|
||
Or | ||
|
||
```js | ||
import { utils } from 'iexec'; | ||
``` | ||
|
||
## errors | ||
|
||
The [errors](./modules/errors.md) namespace exposes the errors thrown by the library, use them if you want specific error handling. | ||
|
||
_example_: | ||
|
||
```js | ||
import errors from 'iexec/errors'; | ||
``` | ||
|
||
Or | ||
|
||
```js | ||
import { errors } from 'iexec'; | ||
``` | ||
|
||
--- | ||
|
||
# Live demos | ||
|
||
- [Buy computation](https://codesandbox.io/embed/876r7?fontsize=14&hidenavigation=1&theme=dark) | ||
- [Deploy and sell application](https://codesandbox.io/embed/l4hh4?fontsize=14&hidenavigation=1&theme=dark) | ||
- [Deploy and sell dataset](https://codesandbox.io/embed/micsl?fontsize=14&hidenavigation=1&theme=dark) | ||
|
||
--- | ||
|
||
[< Back home](../README.md) |
Oops, something went wrong.