User Signing

This is a relatively advanced use case. If you use the signed typed data JSONRPC endpoint, Fortmatic will support this as well.

Signing Methods

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

// Required to convert message to Hex
const ethUtil = require('ethereumjs-util');

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

web3.eth.getAccounts((error, accounts) => {
 
  if (error) throw error;
 
  const from = accounts[0];
  const msg = ethUtil.bufferToHex(new Buffer('YOUR_MESSAGE', 'utf8'));
  const params = [msg, from];
  const method = 'personal_sign';
 
  web3.currentProvider.sendAsync({
    id: 1,
    method,
    params,
    from,
  }, function(error, result) {
    if (error) throw error;
    console.log(result);
  });

});

Last updated