snap_getInterfaceContext
Get the context of an interface
created by snap_createInterface.
Parameters
object
requiredAn object containing the parameters for the snap_getInterfaceContext
method.
id
stringThe interface ID.
Returns
Record<string, JSON> | null
The context for the given interface. May be null if no context was provided
when the interface was created.
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'
// }