📦Install with NPM

You can also easily integrate Fortmatic into your Javascript dApp written in frameworks such as React. Simply run the script below in your project directory to install the Fortmatic Javascript package from NPM.

Recommended Node and NPM versions: Node version >= 6.9 and NPM version >= 3.4

Fortmatic Installation Script

npm install --save fortmatic

Web3 Installation Script

If you are using web3 for your dApp, you can install either the latest stable web3 version or the 1.0 beta version with updated capabilities and syntax. If you are only using the Fortmatic SDK without web3, you may skip this step.

# Install latest web3 1.0.0-beta.x version
npm install --save web3

# Or install stable web3 0.20.x version
npm install --save web3@0.20

Import into Web3 dApp

Use the following code snippet to import Fortmatic into your web3 dApp.

import Fortmatic from 'fortmatic';
// Works for web3 1.0 and pre-1.0 versions
import Web3 from 'web3';

// Pass in the network string value if using test API key
const fm = new Fortmatic('YOUR_API_KEY');
window.web3 = new Web3(fm.getProvider());

// Send transactions the way your are used to
web3.eth.sendTransaction({/* ... */});

Last updated