📈Migrating from v1.x

Attention Web3 Developers!

There are no major breaking changes with regards to Fortmatic's publicly-documented Widget APIs. However, the core library architecture and some private interfaces have changed. We've introduced TypeScript typings in v2.0.0, through which future breaking changes will be measured. If you've built a library or module that depends on Fortmatic's internal methods or properties, please update your code accordingly. For most SDK consumers, no code changes are required.

TypeScript Definitions

As of v2.0.0, the Fortmatic SDK has first-class support for TypeScript typings. Most developers will reap the benefits of strong, static type definitions without blockers, but there are some edge cases to be aware of.

Passing the Fortmatic Provider to Web3

Due to a limitation in the type definition for Web3.js, the Fortmatic provider must be cast to any to avoid a compiler error:

/* TypeScript */
const fm = new Fortmatic('MY_API_KEY');
const web3 = new Web3(fm.getProvider() as any);

Legacy Synchronous Methods are Deprecated

Obsolete beta versions of Web3 depended on synchronous behavior for certain Ethereum methods (such as eth_accounts and net_version). Support for this legacy behavior has been removed in v2.0.0.

Still Using MetaMask's Injected Web3 Instance?

Developers who rely on window.web3 should be aware that MetaMask is deprecating their injected Web3 instance. Instead, consumers of the Fortmatic SDK are advised to manage their own Web3 dependency. If you are keen to support legacy versions of MetaMask, you can still create your own Web3 instance and reference MetaMask's in-page provider like this:

let web3;
if (window.web3 && window.web3.currentProvider) {
  web3 = new Web3(window.web3.currentProvider)

Last updated