For the complete documentation index, see llms.txt. This page is also available as Markdown.

mega.getPermissions()

Read active permission grants. Use this to check whether a grant is still valid before triggering callContract() with silent: true.

The optional address argument switches between two modes:

  • No argument — returns the grants for the connected session's own subject (the common case).

  • With an address — returns the grants delegated to that specific external address (the externalAddress bound during grantPermissions()).

Signature

mega.getPermissions(address?: string): Promise<GetPermissionsResponse | undefined>

Parameters

Field
Type
Required
Notes

address

string

optional

Omit for your session's own grants; pass an address for that delegate's grants.

Example

const grants = await mega.getPermissions('0xDelegatedAddress');

if (!grants || !grants.permissions) {
  console.log('No active grants');
}

Response

The outer response or inner permissions may be null/undefined. Always null-check both before reading.

Notes

  • Compare permissions.expiry against Math.floor(Date.now() / 1000) to know if the grant is still valid.

  • Inspect permissions.spend against your app's tracked consumption to know how much budget is left.

  • Re-grant via grantPermissions() when expired or exhausted.

Last updated