Skip to main content
  • Snap

snap_getInterfaceContext

Description

Get the context of an interface created by snap_createInterface.

Parameters

object

The request parameters for the snap_getInterfaceContext method.

id

string
required

The interface ID.

Returns

Record<string, Json> | null

The context for the given interface.

Example

import { Box, Heading, Text } from "@metamask/snaps-sdk/jsx";

const interfaceId = await snap.request({
method: "snap_createInterface",
params: {
ui: (
<Box>
<Heading>Hello, world!</Heading>
<Text>Welcome to my Snap homepage!</Text>
</Box>
),
context: {
key: "value",
},
},
});

const context = await snap.request({
method: "snap_getInterfaceContext",
params: {
id: interfaceId,
},
});

console.log(context);
// {
// key: 'value'
// }