wallet_snap
Description
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.
Parameters
object
requiredThe request to send to the Snap.
snapId
stringThe ID of the Snap to invoke.
request
Record<string, JSON>The JSON-RPC request to send to the Snap.
Returns
JSON
The result returned by the Snap. The structure of this result will depend on the specific method that was called on the Snap, and is not defined by the API.
Example
const result = await ethereum.request({
method: "wallet_snap",
params: {
snapId: "npm:my-snap",
request: {
method: "hello",
params: { name: "world" },
},
},
});
console.log(result); // "Hello, world!"