metamask-filecoin-developer-beta icon indicating copy to clipboard operation
metamask-filecoin-developer-beta copied to clipboard

The MetaMask Filecoin Developer Preview.

MetaMask Filecoin Developer Preview

Hey, we're hiring JavaScript Engineers! Apply Here.

Welcome to the MetaMask Filecoin Developer Preview. This is a special distribution of the MetaMask extension intended for developers only. It uses a prototype of the MetaMask Snaps plugin system to include a preinstalled version of a Filecoin plugin, called a snap.

Installation

For the latest version, please see Releases. Builds can be installed using these instructions. We recommend creating a new browser profile where you install the Filecoin developer preview. This distribution of the MetaMask extension may not receive all features and bug fixes added to the official, browser store distribution.

Usage

The Filecoin Developer Preview only supports the preinstalled Filecoin snap, and can only be used on Chromium browsers. You can try it out with this dapp.

The Filecoin snap (a.k.a. filsnap) runs within a Secure EcmaScript Compartment inside a Web Worker. The snap can be toggled on and off and reinstalled via the Filecoin dropdown in the main MetaMask menu bar.

The snap manages its own Filecoin keys generated from the user's MetaMask seed phrase according to the BIP-32 and SLIP-44 standards. The snap cannot access the user's seed phrase or any keys other than Filecoin.

To communicate with dapps, the snap extends its own RPC API to sites that connect to it, allowing websites to check the balance of the user's Filecoin address, and send transactions. It's the dapp's responsibility to display the user's FIL balance, send and receive transactions and messages, etc. There is no UI representation of FIL in MetaMask at this prototype stage.

To understand how to connect to and talk to the snap, see the source code of the example dapp.

In short, to connect to the snap, you make the following call over MetaMask's window.ethereum API:

await window.ethereum.request({
  method: "wallet_enable",
  params: [{
    filsnap: {}
  }]
});

If that call succeeds, you can communicate with the plugin as follows:

await window.ethereum.request({
  method: "wallet_invokePlugin",
  params: ['filsnap', {
    method: 'fil_getBalance',
  }]
});

For a list of available methods, see here.

Note that some methods take parameters, for example:

const mesage = // Your message

await window.ethereum.request({
  method: "wallet_invokePlugin",
  params: ['filsnap', {
    method: 'fil_signMessage',
    params: { message }
  }]
});

For related repositories and documentation, please see:

Kudos to our friends at NodeFactory for the original implementation of the Filecoin snap and dapp.

About MetaMask

You can find the latest version of MetaMask on our official website. We do not offer customer support for the Filecoin Developer Preview, but please open an issue if anything is amiss.

For the regular MetaMask extension repository, go here.