Skip to content
Dan Forbes edited this page Jun 20, 2024 · 17 revisions

The Polkadot Wallet snap extends MetaMask capabilities to include support for Polkadot, Kusama, and other Substrate- and FRAME-based blockchains in the Polkadot ecosystem.

This wiki covers the Polkadot Wallet snap architecture, integration steps and detailed API documentation for dApp developers. There is also a usage guide for the example dApp.

What Are Snaps?

Snaps allow developers to safely extend the capabilities of MetaMask. A snap is a program that MetaMask runs in an isolated environment that can customize the wallet experience.

For example, a snap can add new APIs to MetaMask, add support for different blockchain protocols, or modify existing functionality using internal APIs. Snaps are a new way to create web3 end-user experiences by modifying MetaMask in ways that were impossible before 🚀

Learn more about snaps from the official MetaMask documentation.

Contents

Architecture

The MetaMask Polkadot Wallet snap is enabled through the metamask-polkadot-adapter. The procedure is represented in the diagram below and described in more detail inside integration steps.

Once the snap is installed, a new Polkadot account is generated. Account details such as address, public key, and balance can be obtained through the Polkadot Wallet snap API. The snap can also be used to sign transactions and submit them to the network.

Integration

Follow these steps to add support for the Polkadot Wallet snap to your dApp.

Steps

  1. Add the metamask-polkadot-adapter package to your project.

npm i @chainsafe/metamask-polkadot-adapter

  1. [Optional] Add types for the adapter to your project in case you will interact with snap specific API.

npm i @chainsafe/metamask-polkadot-types

  1. Enable the Polkadot Wallet snap by calling enablePolkadotSnap from the @chainsafe/metamask-polkadot-adapter package.

Refer to the source code of the example dApp (in particular, the MetaMaskConnector container and the metamask service) for more details.

Clone this wiki locally