Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
---
description: Install Snaps dependencies.
description: Install MetaMask Flask to start building your own Snaps.
sidebar_position: 1
---

# Install Snaps
# Install MetaMask Flask

To get started building your own snaps, you must [install the MetaMask Flask browser extension](#install-the-metamask-flask-browser-extension).

:::danger Developers only
MetaMask Flask is an experimental tool only for developers.
If you are not a developer, you should not install MetaMask Flask.
:::

## Prerequisites

- Up-to-date Chromium or Firefox browser
Expand Down
12 changes: 6 additions & 6 deletions snaps/get-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ With the CLI, you can initialize a snap monorepo project built with TypeScript a

## Prerequisites

- [Snaps installed](install-snaps.md)
- [MetaMask Flask installed](install-flask.md)

:::tip
Snaps works with the latest LTS version of Node.js, but we recommend using the version specified in
MetaMask Snaps works with the latest LTS version of Node.js, but we recommend using the version specified in
the template's [`.nvmrc`](https://github.com/MetaMask/template-snap-monorepo/blob/main/.nvmrc) file.
:::

Expand Down Expand Up @@ -50,15 +50,15 @@ Start the development server:
yarn start
```

You are now serving the snap and its front-end at [`http://localhost:8000`](http://localhost:8000/).
You are now serving the snap at [`http://localhost:8080`](http://localhost:8080/) and its front-end at [`http://localhost:8000`](http://localhost:8000/).

## Connect to the snap

On the front-end, select the **Connect** button and the MetaMask Flask extension pops up and
requires you to approve the snap's permissions.

Once connected, select the **Send message** button to display a custom message within a confirmation
screen in MetaMask.
screen in MetaMask Flask.

## Customize the snap

Expand Down Expand Up @@ -94,11 +94,11 @@ export const onRpcRequest: OnRpcRequestHandler = ({ origin, request }) => {
};
```

Edit the text in the `description` or `textAreaContent` field and select the **Reconnect** button
Edit the text in any `text()` component and select the **Reconnect** button
on the front-end to re-install the snap.

:::note
MetaMask automatically re-installs locally hosted snaps whenever it receives a connection request
MetaMask Flask automatically re-installs locally hosted snaps whenever it receives a connection request
for them.
:::

Expand Down
29 changes: 15 additions & 14 deletions snaps/how-to/develop-a-snap.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ sidebar_position: 1
# Develop a snap

A snap can extend the dapp-facing [MetaMask JSON-RPC API](/wallet/reference/rpc-api) in
arbitrary ways, or integrate with and extend the functionality of MetaMask using the
[Snaps JSON-RPC API](../reference/rpc-api.md) and [permissions](request-permissions.md).
arbitrary ways, or integrate with and extend the functionality of MetaMask using the [Snaps Exports](../reference/exports.md), [Snaps JSON-RPC API](../reference/rpc-api.md), and [permissions](request-permissions.md).

Before developing a snap, it's important to understand:

- [The snap anatomy](../concepts/anatomy.md).
- [The snap lifecycle](../concepts/lifecycle.md).
- [The snap user interface](../concepts/user-interface.md).
- [The Snaps execution environment](../concepts/execution-environment.md).
- [The MetaMask Snaps execution environment](../concepts/execution-environment.md).

You can [get started quickly using the Snaps template](../get-started/quickstart.md) or follow a
[tutorial](/snaps/category/tutorials).
Expand All @@ -23,8 +22,7 @@ This page describes additional important steps when developing a snap.

## Detect the user's MetaMask version

When developing a website that depends on Snaps, you need to know whether the user has
[MetaMask Flask](../get-started/install-snaps.md#install-metamask-flask) installed.
When developing a website that depends on [MetaMask Flask](../get-started/install-flask.md#install-metamask-flask), you first need to know whether the user has it installed.

The following example uses the
[`@metamask/detect-provider`](https://npmjs.com/package/@metamask/detect-provider) package to get
Expand Down Expand Up @@ -55,6 +53,11 @@ if (provider && isFlask) {
Test your snap by hosting it locally using `mm-snap serve`, installing it in Flask, and calling its
API methods from a web page.

:::note
If you use the template snap monorepo, running `yarn start` will serve the snap at
[`http://localhost:8080`](http://localhost:8080/)
:::

## Debug your snap

To debug your snap, use `console.log` and inspect the MetaMask background process.
Expand Down Expand Up @@ -86,6 +89,9 @@ on publishing to the public registry.
The following details are specific to Snaps:

- The version in `package.json` and `snap.manifest.json` must match.
- The `repository.url` field in `package.json` should match the correct repository for your snap.
- The `source.location.npm.packageName` in `snap.manifest.json` must match the name in `package.json`.
- The `proposedName` in `snap.manifest.json` should be a human-readable name and should not include the words "MetaMask" or "Snap."
- The image specified in `iconPath` in the manifest file is used as the icon displayed when installing the snap, in custom dialogs, and in the settings menu.
- This icon must be a valid SVG.
- The icon will be cropped in a circle when displayed in MetaMask; you do not need to make the icon circular.
Expand All @@ -97,19 +103,15 @@ If you are using the snap template, make sure to only publish the snap package i
You can use the [Snaps Simulator](https://metamask.github.io/snaps/snaps-simulator/staging/#/manifest) to verify
that your snap was published correctly — just click on "localhost" in the top right corner and change the
snap location to be "npm" and the ID of your snap.

Also, make sure to update the manifest file, icon file, and README to differentiate your snap from the template.
:::

## Distribute your snap

Since snaps are currently intended for a developer audience, MetaMask doesn't currently facilitate
distributing snaps to a wide audience.
If you have a website that expects the user to install a snap, ask the user to install MetaMask
Flask, and then ask the user to install the snap using the
[`wallet_enable`](../reference/rpc-api.md#wallet_enable) API method.
You should deploy a dapp where users can learn about your snap and install it, or integrate with your existing dapp.

In the future, MetaMask will create some way for users to more easily discover snaps, but everyone
can always build, publish, and use snaps without MetaMask's permission.
(Although we may try to make it difficult to use known scams.)
If your snap is designed to communicate with dapps, you can encourage other dapp developers to [integrate your snap](work-with-existing-snaps.md).

## Resources and tools

Expand All @@ -119,7 +121,6 @@ You can review the growing number of [example snaps](https://github.com/MetaMask
- [StarkNet](https://github.com/Consensys/starknet-snap)
- [MobyMask Phishing Warning](https://github.com/Montoya/mobymask-snap)
- [Transaction Simulation with Ganache](https://github.com/Montoya/tx-simulation-with-ganache-snap)
(uses Truffle for local testing)

MetaMask also maintains tools to help developers build, debug, and maintain snaps:

Expand Down
2 changes: 1 addition & 1 deletion snaps/how-to/request-permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ For example, your snap can request permission to call the Ethereum provider's
[`eth_accounts`](../reference/permissions.md#eth_accounts) RPC method by calling the provider's
[`eth_requestAccounts`](/wallet/reference/eth_requestaccounts) RPC method.

See the [Ethereum JSON-RPC API restricted methods](/wallet/concepts/rpc-api#restricted-methods)
See the [`eth_accounts` Dynamic Permission](../reference/permissions.md#eth_accounts)
for more information.
15 changes: 7 additions & 8 deletions snaps/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import CardList from '@site/src/components/CardList'

# Extend the functionality of MetaMask using Snaps

Snaps is an open source system that allows anyone to safely extend the functionality of MetaMask,
MetaMask Snaps is an open source system that allows anyone to safely extend the functionality of MetaMask,
creating new web3 end user experiences.

Get started by [installing Snaps](get-started/install-snaps.md).
Want to build your own Snaps? Get started by [installing MetaMask Flask](get-started/install-flask.md).

:::note
- Snaps is pre-release software.
- To learn how to integrate your dapp with MetaMask, visit the
[MetaMask wallet developer documentation](../wallet).
To learn how to integrate your dapp with MetaMask, visit the
[MetaMask wallet developer documentation](../wallet).
:::

## What is a snap?
Expand Down Expand Up @@ -85,6 +84,6 @@ Features include:

## Questions?

If you have questions about using Snaps or want to propose a new feature, you can interact with the
Snaps team and community on [GitHub discussions](https://github.com/MetaMask/snaps-monorepo/discussions)
and the Snaps channel on [Consensys Discord](https://discord.gg/consensys).
If you have questions about using MetaMask Snaps or want to propose a new feature, you can interact with the
MetaMask Snaps team and community on [GitHub discussions](https://github.com/MetaMask/snaps-monorepo/discussions)
and the Snaps Dev channel on [Consensys Discord](https://discord.gg/consensys).
4 changes: 2 additions & 2 deletions snaps/tutorials/gas-estimation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ sidebar_position: 1

This tutorial walks you through creating a snap that estimates gas fees.
The snap uses the `fetch` API to request information from the internet, and displays custom
information in a confirmation dialog.
information in an alert dialog.

## Prerequisites

- [Snaps installed](../get-started/install-snaps.md)
- [MetaMask Flask installed](../get-started/install-flask.md)
- A text editor (for example, [VS Code](https://code.visualstudio.com/))
- [Yarn](https://yarnpkg.com/) version 3

Expand Down
2 changes: 1 addition & 1 deletion snaps/tutorials/transaction-insights.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The snap provides transaction insights in the MetaMask transaction window.

## Prerequisites

- [Snaps installed](../get-started/install-snaps.md)
- [MetaMask Flask installed](../get-started/install-flask.md)

- An account on your MetaMask Flask instance with testnet ETH

Expand Down