snap_getInterfaceContext
Description
Get the context of an interface
created by snap_createInterface.
Parameters
id
stringrequiredThe 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'
// }