iexec / Exports
Use the iExec decentralized marketplace for off-chain computing in your dapp.
Install iexec sdk
npm install iexec
import { IExec } from 'iexec';
// connect injected provider
const iexec = new IExec({ ethProvider: window.ethereum });
Read more about popular bundlers integration
import { IExec, utils } from 'iexec';
const { PRIVATE_KEY } = process.env;
const ethProvider = utils.getSignerFromPrivateKey(
'http://localhost:8545', // blockchain node URL
PRIVATE_KEY,
);
const iexec = new IExec({
ethProvider,
});
IExec SDK is split into IExecModules, each providing a set of methods relatives to a specific field.
Additionally the IExec module exposes all the following listed modules under the corresponding namespace.
- IExecAccountModule exposes account methods
- IExecAppModule exposes app methods
- IExecDatasetModule exposes dataset methods
- IExecDealModule exposes deal methods
- IExecENSModule exposes ENS methods
- IExecHubModule exposes hub methods
- IExecNetworkModule exposes network methods
- IExecOrderModule exposes order methods
- IExecOrderbookModule exposes orderbook methods
- IExecResultModule exposes result methods
- IExecSecretsModule exposes secrets methods
- IExecStorageModule exposes storage methods
- IExecTaskModule exposes task methods
- IExecVoucherModule exposes voucher methods
- IExecWalletModule exposes wallet methods
- IExecWorkerpoolModule exposes workerpool methods
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 independent package under iexec/MODULE_NAME
and is exported in the umbrella package.
example:
- import from module package
import IExecWalletModule from 'iexec/IExecWalletModule';
- import from umbrella
import { IExecWalletModule } from 'iexec';
IExecModules are instantiated with an IExecConfig providing the configuration to access to a specific instance of the iExec platform.
Once created, an IExecConfig can be shared with any IExecModule.
example:
- standard usage
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 instantiated module configuration
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 instantiation (shorter but not recommended)
import IExecWalletModule from 'iexec/IExecWalletModule';
// the IExecConfig step can be skipped
const wallet = new IExecWalletModule({ ethProvider: window.ethereum });
The utils namespace exposes some utility methods.
example:
import utils from 'iexec/utils';
Or
import { utils } from 'iexec';
The errors namespace exposes the errors thrown by the library, use them if you want specific error handling.
example:
import errors from 'iexec/errors';
Or
import { errors } from 'iexec';