Skip to main content

ExecutionService Actions

4 actions registered.

NameDeprecated
executeSnap
handleRpcRequest
terminateAllSnaps
terminateSnap

ExecutionService:executeSnap​

Package: @metamask/snaps-controllers

Initializes and executes a Snap, setting up the communication channels to the Snap etc.

Parameters:

NameDescription
snapDataData needed for Snap execution.
snapData.snapIdThe ID of the Snap to execute.
snapData.sourceCodeThe source code of the Snap to execute.
snapData.endowmentsThe endowments available to the executing Snap.

Returns: A string OK if execution succeeded.

Handler signature:

({ snapId, sourceCode, endowments, }: SnapExecutionData) => Promise<string>

ExecutionService:handleRpcRequest​

Package: @metamask/snaps-controllers

Handle RPC request.

Parameters:

NameDescription
snapIdThe ID of the recipient Snap.
optionsBag of options to pass to the RPC handler.

Returns: Promise that can handle the request.

Handler signature:

(snapId: string, options: SnapRpcHookArgs) => Promise<unknown>

ExecutionService:terminateAllSnaps​

Package: @metamask/snaps-controllers

Handler signature:

() => Promise<void>

ExecutionService:terminateSnap​

Package: @metamask/snaps-controllers

Terminates the Snap with the specified ID and deletes all its associated data. Any subsequent messages targeting the Snap will fail with an error. Throws an error if termination fails unexpectedly.

Parameters:

NameDescription
snapIdThe id of the Snap to be terminated.

Handler signature:

(snapId: string) => Promise<void>