Skip to main content
  • Snap
  • Website

wallet_requestSnaps

Description

Request permission for a dapp to communicate with the specified Snaps and attempt to install them if they're not already installed.

If the Snap version range is 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 successfully installed.

If the installation of any Snap fails, or the user rejects the installation or permission request, this method returns the error that caused the failure.

Parameters

Record<string, { version?: string }>

An object mapping the IDs of the requested Snaps to optional SemVer version ranges. The SemVer version ranges use the same semantics as NPM package.json ranges.

Returns

Record<string, { error: JsonRpcError } | Snap>

An object mapping the IDs of the requested Snaps to either the installed Snap or an error if the Snap failed to install or was not permitted.