Fortmatic
WebsiteDashboardSupport
v2.x
v2.x
  • 🚀Get Started
  • 📦Install with NPM
  • 🧩Examples
  • 💬FAQ
  • 📈Migrating from v1.x
  • Web3 Integration
    • Web3 Provider
    • Network Configuration
    • Binance Smart Chain
    • Get User Account
    • Send Ether Transaction
    • Smart Contract Functions
    • User Signing
    • SDK Error Handling
    • Batch Request
  • Smart Contract
    • ERC20 Transfer
    • ERC20 Approve
    • ERC20 TransferFrom
    • Generic Contract Call
  • Fortmatic Native
    • Log In
    • Log Out
    • Is User Logged In
    • Compose Transaction
    • Deposit Address
    • Configuration
  • More
    • Fiat On-ramp
    • Domain Verification
Powered by GitBook
On this page

Was this helpful?

  1. Fortmatic Native

Log In

PreviousGeneric Contract CallNextLog Out

Last updated 5 years ago

Was this helpful?

The Fortmatic SDK offers it's own end point for logging users into their Fortmatic wallets.

// Initialize provider
import Fortmatic from 'fortmatic';
import Web3 from 'web3';

const fm = new Fortmatic('YOUR_API_KEY');
window.web3 = new Web3(fm.getProvider());

fm.user.login().then(() => {
  web3.eth.getAccounts().then(console.log); // ['0x...']
});

Users will be prompted with a Fortmatic login dialog, after which their wallet information will be returned to the SDK (similar to ).

Customizing Login Behavior

// Initialize provider
import Fortmatic from 'fortmatic';
import Web3 from 'web3';

const fm = new Fortmatic('YOUR_API_KEY');
window.web3 = new Web3(fm.getProvider());

fm.configure({ primaryLoginOption: 'email' }).then(() => {
  fm.user.login().then(() => {
    web3.eth.getAccounts().then(console.log); // ['0x...']
  });
});

Currently the following options are supported for primaryLoginOption:

  • 'email'

  • 'phone'

Users have the optionality to log in with email or password and developers can customize which option takes precedence using the method, like so:

Fortmatic.configure
Get User Account