|
| 1 | +--- |
| 2 | +sip: 22 |
| 3 | +title: MetaMask URL scheme |
| 4 | +status: Draft |
| 5 | +author: Christian Montoya (@Montoya), Hassan Malik (@hmalik88) |
| 6 | +created: 2024-09-13 |
| 7 | +--- |
| 8 | + |
| 9 | +## Abstract |
| 10 | + |
| 11 | +This SIP describes a URL scheme for extension navigation. The described URL will allow for navigation to Snaps entry points and elsewhere within the MetaMask extension. This scheme can potentially be used by Snap methods in the future to navigate the user to a location in-client and trigger the entry point. |
| 12 | + |
| 13 | +## Motivation |
| 14 | + |
| 15 | +While some Snap entry points are reactive, meaning they can be triggered by a method, others can only be triggered by a user navigating to the location where that entry point is displayed. In order for a Snap to programmatically navigate a user to that entry point, the Snap needs a way to identify that location. The location is identified by a URL scheme, and an in-client link pointing to this location is called a _deep link_. |
| 16 | + |
| 17 | +## Specification |
| 18 | + |
| 19 | +### Language |
| 20 | + |
| 21 | +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", |
| 22 | +"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and |
| 23 | +"OPTIONAL" written in uppercase in this document are to be interpreted as described in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt) |
| 24 | + |
| 25 | +### URL Scheme |
| 26 | + |
| 27 | +[URL syntax](https://en.wikipedia.org/wiki/URL#Syntax) is defined with a scheme, authority, path, and with optional (query and fragment) portions. This SIP defines a new scheme: `metamask:`, the syntax is defined below: |
| 28 | + |
| 29 | +`metamask://[authority]/[path]` |
| 30 | + |
| 31 | +Where: |
| 32 | + |
| 33 | +- `[authority]` refers to either `client` or `snap` (in the current case, `client` can mean either the extension or mobile version of MetaMask) |
| 34 | +- `[path]` refers to the entire path which depending on the authority can be different |
| 35 | + - For the `client` authority, the following paths are available: |
| 36 | + - `/` - links to the client's home page |
| 37 | + - For the `snap` authority, the path starts with the snap ID and has the following paths available to it: |
| 38 | + - `/home` - leads to the snap's [home page](/SIPS/sip-15.md) (which is its settings page if it doesn't have a home page) |
| 39 | + |
| 40 | +> [!NOTE] |
| 41 | +> 1. In the future, fragments can potentially be used for navigation to specific portions of a page and params can be provided from a calling method for exports such as `onHome`. |
| 42 | +> 2. This URL scheme assumes parity between `client` locations. |
| 43 | +
|
| 44 | +### Examples |
| 45 | + |
| 46 | +The proposed URL for the Starknet Snap home page: |
| 47 | + |
| 48 | +`metamask://snap/npm:@consensys/starknet-snap/home` |
| 49 | + |
| 50 | +The URL for navigating to the client's home page: |
| 51 | + |
| 52 | +`metamask://client/` |
| 53 | + |
| 54 | +### Using Deep Links |
| 55 | + |
| 56 | +A Snap will be able to navigate to these links using the [SIP-7](https://github.com/MetaMask/SIPs/blob/main/SIPS/sip-7.md) `Link` component. |
| 57 | + |
| 58 | +## Copyright |
| 59 | + |
| 60 | +Copyright and related rights waived via [CC0](../LICENSE). |
0 commit comments