This project is a MetaMask snap that lets users add Unlock Protocol keys and locks as assets. After clicking "Connect" and allowing the snap permission to manage assets, all of the connected wallet's locks and keys can be added automatically by clicking "Add Unlock Protocol Assets". Every key is listed as its own NFT (ERC-721), and the balance here will be always 1 for each account, due to Unlock Protocol's key implementation. Locks are aggregated, so the balance shows the number of locks this account owns.

Metamask Snap: Add Unlock Protocol Assets showcase

How it's made

This snap implements an "addUnlockAssets" method, that takes two parameters: locks and keys. The connected wallet's locks and keys are retrieved via the corresponding network's official Unlock Protocol subgraph. The code is based on MetaMask's official snap-cli example. Originally we set out to enable custom images for the keys, but we couldn't get the assets' images to display in MetaMask. This is somethin we're interested in looking into further.

Technologies used