Skip to main content
  • Snap

snap_getClientStatus

Description

Get the status of the client running the Snap.

Returns

object

The result returned by the snap_getClientStatus method.

It returns an object containing useful information about the client.

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.

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();
}
};