wallet_invokeSnap
Description
Invoke a method of a Snap, designated by the snapId parameter, with a
JSON-RPC request specified in the request parameter. This is effectively a
wrapper around wallet_snap
that allows for more convenient invocation of Snap methods without needing to
specify the full wallet_snap parameters.
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.
Parameters
snapId
stringrequiredThe ID of the Snap to invoke.
request
Record<string, Json>requiredThe JSON-RPC request to send to the Snap.
Returns
Json
The result of the Snap method call.
Example
const result = await snap.request({
method: "wallet_invokeSnap",
params: {
snapId: "npm:@metamask/example-snap",
request: {
method: "someMethod",
params: { some: "params" },
},
},
});