Skip to main content
  • Snap

snap_getClientStatus

Description

Get the status of the client running the Snap.

Parameters

This method does not have any parameters.

Returns

object

An object containing information about the client that the Snap is running in.

clientVersion

string

The semantic version of the client that the Snap is running in.

platformVersion

string

The Snaps platform version that the client is running.

locked

boolean

A boolean flag that indicates whether the client is locked or not.

active

boolean

A boolean flag that indicates whether the client is active or not. The client is considered active if the client is visible.

Example

import type { OnCronjobHandler } from "@metamask/snaps-sdk";
import { MethodNotFoundError } from "@metamask/snaps-sdk";

export const onCronjob: OnCronjobHandler = async ({ request }) => {
switch (request.method) {
case "execute":
// Find out if MetaMask is locked.
const { locked } = await snap.request({
method: "snap_getClientStatus",
});

if (!locked) {
// Do something that requires MetaMask to be unlocked, such as
// accessing the encrypted state.
}

default:
throw new MethodNotFoundError();
}
};