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 (theexternalAddressbound duringgrantPermissions()).
Signature
mega.getPermissions(address?: string): Promise<GetPermissionsResponse | undefined>
Parameters
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.expiryagainstMath.floor(Date.now() / 1000)to know if the grant is still valid.Inspect
permissions.spendagainst your app's tracked consumption to know how much budget is left.Re-grant via
grantPermissions()when expired or exhausted.
Last updated