Esc

View as Markdownllms.txt

Get Permissions

Check if permissions have been granted and have not expired.

import { mega } from '@megaeth-labs/wallet-sdk';

const result = await mega.getPermissions();

if (result?.permissions) {
    console.log('Expires', new Date(result.permissions.expiry * 1000));
}
Runs on testnet with your wallet
ts
// Takes an optional address; defaults to the connected account.
interface GetPermissionsResponse {
    permissions?: {
        expiry: number;
        permissions: {
            calls: { signature: string; to: `0x${string}` }[];
            spend: {
                limit: bigint;
                period: 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
                token?: `0x${string}`;
            }[];
        };
    } | null;
}