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)
Start a new project β
In this section, we will show you how to set up and call the different methods of the SDK in JS app.
You can reach the following open-source GitHub project, clone it and start from there.
You can find the project here.
Installation β
npm install @iexec/iexec-oracle-factory-wrapper
yarn add @iexec/iexec-oracle-factory-wrapper
pnpm add @iexec/iexec-oracle-factory-wrapper
bun add @iexec/iexec-oracle-factory-wrapper
This package is an ESM package. Your project needs to use ESM too.Read more.
When deployed with WebPack, the Web3Mail tool requires WebPack version 5 or greater. You can refer to our sample WebPack project for more information.
Instantiate SDK β
Import and initialize the Oracle Factory SDK in your application.
import { IExecOracleFactory } from '@iexec/iexec-oracle-factory-wrapper';
const web3Provider = window.ethereum;
// instantiate
const factory = new IExecOracleFactory(web3Provider);
import { IExecOracleFactory, utils } from '@iexec/iexec-oracle-factory-wrapper';
const { PRIVATE_KEY } = process.env;
// get web3 provider from a private key
const signer = utils.getSignerFromPrivateKey(
'https://bellecour.iex.ec',
'your-private-key'
);
const factory = new IExecOracleFactory(signer);
Instantiate only IExecOracleReader
β
Import and initialize the IExecOracleReader
from the Oracle Factory SDK in your application.
import { IExecOracleReader } from '@iexec/iexec-oracle-factory-wrapper';
// instantiate
const mainnetBlockchainReader = new IExecOracleReader('mainnet');
import { IExecOracleReader } from '@iexec/iexec-oracle-factory-wrapper';
// instantiate
const mainnetBlockchainReader = new IExecOracleReader('mainnet');
TIP
You can initialize the IExecOracleReader
with the blockchain name
or the chain id
or even your custom blockchain endpoint.
Supported blockchains:
blockchain name | chainID |
---|---|
mainnet | 1 |
bellecour | 134 |
polygon | 137 |
Sandbox β
β‘ Β Code SandboxCorresponding GitHub repository:
π Β GitHub repository sandbox