wallet_requestSnaps
Requests permission for a dapp to communicate with the specified Snaps and attempts to install them if they're not already installed. If the installation of any Snap fails, returns the error that caused the failure.
Params
(1)1. RequestSnapsParameter (required)
An object mapping the IDs of requested Snaps to optional SemVer version ranges.
(Optional) A SemVer version range for the Snap. This uses the same semantics as npm package.json ranges. If specified, MetaMask attempts to install a version of the Snap that satisfies the range. If a compatible version of the Snap is already installed, the request succeeds. If an incompatible version is installed, MetaMask attempts to update the Snap to the latest version that satisfies the range. The request succeeds if the Snap is succesfully installed.
Result
(RequestSnapsResult)An object mapping the IDs of installed Snaps to their metadata.
The ID of the Snap.
The initial permissions of the Snap, which will be requested when the Snap is installed.
The version of the Snap.
Indicates whether the Snap is enabled.
Indicates whether the Snap is blocked.
Example
Request
await window.ethereum.request({
"method": "wallet_requestSnaps",
"params": [
{
"npm:@metamask/example-snap": {},
"npm:fooSnap": {
"version": "^1.0.2"
}
}
]
});
Result
{
"npm:@metamask/example-snap": {
"version": "1.0.0",
"id": "npm:@metamask/example-snap",
"enabled": true,
"blocked": false
},
"npm:fooSnap": {
"version": "1.0.5",
"id": "npm:fooSnap",
"enabled": true,
"blocked": false
}
}