Skip to content

Getting Started

GitHub package.json version (branch)

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

sh
npm install @iexec/web3mail
sh
yarn add @iexec/web3mail
sh
pnpm add @iexec/web3mail
sh
bun add @iexec/web3mail

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 working project here.

Instantiate with a Web3 Provider

ts
import { 
IExecWeb3mail
} from '@iexec/web3mail';
const
web3Provider
=
window
.
ethereum
;
// instantiate const
web3mail
= new
IExecWeb3mail
(
web3Provider
);
ts
import { 
IExecWeb3mail
,
getWeb3Provider
} from '@iexec/web3mail';
// get web3 provider from a private key const
web3Provider
=
getWeb3Provider
('YOUR_PRIVATE_KEY', 'RPC_URL');
// instantiate const
web3mail
= new
IExecWeb3mail
(
web3Provider
);

Instantiate Without a Web3 Provider

For projects that only require read functions, you can instantiate the SDK without a Web3 provider.

ts
import { 
IExecWeb3mail
} from '@iexec/web3mail';
// instantiate const
web3mail
= new
IExecWeb3mail
('RPC_URL');
ts
import { 
IExecWeb3mail
,
getWeb3Provider
} from '@iexec/web3mail';
// instantiate const
web3mail
= new
IExecWeb3mail
('RPC_URL');