Getting Started β
Overview β
Prerequisites β
Before getting started, ensure that you have the following installed on your system:
- Node.js version 18 or higher
- NPM (Node.js package manager)
Installation β
npm install @iexec/dataprotector
yarn add @iexec/dataprotector
pnpm add @iexec/dataprotector
bun add @iexec/dataprotector
This package is an ESM package. Your project needs to use ESM too. Β Read more
If you use it with Webpack, some polyfills will be needed. You can find a minimal working project here.
Instantiate SDK β
Depending on your project's requirements, you can instantiate the SDK using the umbrella module for full functionality or opt for one of the submodules to access specific sets of features.
Instantiate using the umbrella module β
For projects requiring the full functionality of the SDK, including both core and sharing functions.
import { IExecDataProtector } from '@iexec/dataprotector';
const web3Provider = window.ethereum;
// Instantiate using the umbrella module for full functionality
const dataProtector = new IExecDataProtector(web3Provider);
const dataProtectorCore = dataProtector.core;
const dataProtectorSharing = dataProtector.sharing;
import { IExecDataProtector, getWeb3Provider } from '@iexec/dataprotector';
// Get Web3 provider from a private key
const web3Provider = getWeb3Provider('YOUR_PRIVATE_KEY');
// Instantiate using the umbrella module for full functionality
const dataProtector = new IExecDataProtector(web3Provider);
const dataProtectorCore = dataProtector.core; // access to core methods
const dataProtectorSharing = dataProtector.sharing; // access to methods
Instantiate only the core
module β
For projects focusing solely on core data protection functions.
import { IExecDataProtectorCore } from '@iexec/dataprotector';
const web3Provider = window.ethereum;
// Instantiate only the Core module
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
// Get Web3 provider from a private key
const web3Provider = getWeb3Provider('YOUR_PRIVATE_KEY');
// Instantiate only the Core module
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
Instantiate only the sharing
module β
For projects that need access management functions specifically.
import { IExecDataProtectorSharing } from '@iexec/dataprotector';
const web3Provider = window.ethereum;
// Instantiate only the Sharing module
const dataProtectorSharing = new IExecDataProtectorSharing(web3Provider);
import {
IExecDataProtectorSharing,
getWeb3Provider,
} from '@iexec/dataprotector';
// Get Web3 provider from a private key
const web3Provider = getWeb3Provider('YOUR_PRIVATE_KEY');
// Instantiate only the Sharing module
const dataProtectorSharing = new IExecDataProtectorSharing(web3Provider);
Instantiate without a Web3 provider β
For projects that only require read functions, you can instantiate the SDK without a Web3 provider.
import {
IExecDataProtectorSharing,
IExecDataProtectorCore,
} from '@iexec/dataprotector';
// Instantiate only the Core module for read-only core methods
const dataProtectorCore = new IExecDataProtectorCore();
// Instantiate only the Sharing module for read-only sharing methods
const dataProtectorSharing = new IExecDataProtectorSharing();
import { IExecDataProtector } from '@iexec/dataprotector';
// Instantiate using the umbrella module for read-only functions
const dataProtector = new IExecDataProtector();
// Access to read-only core methods
const dataProtectorCore = dataProtector.core;
// Access to read-only sharing methods
const dataProtectorSharing = dataProtector.sharing;
Advanced configuration β
To add optional parameters, see advanced configuration.
Sandbox β
Core methods β
β‘ Β Code SandboxCorresponding GitHub repository:
π Β GitHub repository sandboxSharing methods β
β‘ Β Code SandboxCorresponding GitHub repository:
π Β GitHub repository sandbox