Skip to main content
  • Snap

snap_getInterfaceState

Description

Get the form state of an interface created by snap_createInterface.

Parameters

id

stringrequired

The interface ID.

Returns

Record<string, { addresses: `${string}:${string}:${string}`[]; accountId: string } | { name: string; size: number; contentType: string; contents: string } | { symbol: string; name: string; asset: `${string}:${string}/${string}:${string}` } | boolean | Record<string, { addresses: `${string}:${string}:${string}`[]; accountId: string } | { name: string; size: number; contentType: string; contents: string } | { symbol: string; name: string; asset: `${string}:${string}/${string}:${string}` } | boolean | string | null> | string | null>

The state of the given interface. This is a Record of the form state, where the keys are the name properties of the form fields, and the values are the current values of those fields, depending on the type of the field.

For example, for a text field, the value would be a string, for a checkbox field, the value would be a boolean, and for a file upload field, the value would be a File object. The exact structure of the state depends on the form fields that were defined when the interface was created.

Example

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