Skip to main content
  • Snap

snap_getBackgroundEvents

Description

Get the scheduled background events for the Snap.

Parameters

This method does not have any parameters.

Returns

object[]

An array of scheduled background events.

object

Background event type.

Note: The date generated when scheduling an event with a duration will be represented in UTC.

id

string

The unique ID representing the event.

scheduledAt

string

The ISO 8601 timestamp of when the event was scheduled.

snapId

SnapId

The ID of the Snap that scheduled the event.

date

string

The ISO 8601 date of when the event is scheduled for.

request

object

The request that is supplied to the onCronjob handler when the event is fired.

method

string

The method to be called when the event is fired.

jsonrpc

"2.0" | null

The optional JSON-RPC version for the request, which is always "2.0" if provided.

id

number | string | null

The optional ID for the request.

params

JsonRpcParams

The optional parameters for the request.

Example

const events = await snap.request({
method: "snap_getBackgroundEvents",
});
console.log(events);
// [
// {
// id: 'event-1',
// scheduledAt: 1672531200000,
// snapId: 'npm:example-snap',
// date: 1672531200000,
// request: {
// method: 'example_method',
// params: { example: 'data' },
// },
// },
// ...,
// ]