Skip to main content

wallet_snap

MetaMaskSnapsRestricted

Calls the specified JSON-RPC API method of the specified Snap. The Snap must be installed and the dapp must have permission to communicate with the Snap, or the request is rejected. The dapp can install the Snap and request permission to communicate with it using wallet_requestSnaps.

This method is synonymous to wallet_invokeSnap.

Params

(1)

1. SnapParameter (required)

snapId
string

The ID of the Snap to invoke.

request
object

The JSON-RPC request object to send to the invoked Snap.

method
string
params
object

Result

(SnapResult)

Result of the Snap method call.

Example

Request

await window.ethereum.request({
"method": "wallet_snap",
"params": [
{
"snapId": "npm:@metamask/example-snap",
"request": {
"method": "hello"
}
}
]
});

Result

{}

Params

SnapParameter

request
params

Request

await window.ethereum.request({
"method": "wallet_snap",
"params": [
null
]
});