import { getPermissionStatus } from "@base-org/account/spend-permission";// Check the status of a permission (no client needed)const status = await getPermissionStatus(permission);console.log(`Remaining spend: ${status.remainingSpend} wei`);console.log(`Next period starts: ${status.nextPeriodStart}`);console.log(`Is revoked: ${status.isRevoked}`);console.log(`Is expired: ${status.isExpired}`);console.log(`Is active: ${status.isActive}`);if (status.isActive && status.remainingSpend > BigInt(0)) { console.log('Permission can be used for spending');}
import { getPermissionStatus } from "@base-org/account/spend-permission";// Check the status of a permission (no client needed)const status = await getPermissionStatus(permission);console.log(`Remaining spend: ${status.remainingSpend} wei`);console.log(`Next period starts: ${status.nextPeriodStart}`);console.log(`Is revoked: ${status.isRevoked}`);console.log(`Is expired: ${status.isExpired}`);console.log(`Is active: ${status.isActive}`);if (status.isActive && status.remainingSpend > BigInt(0)) { console.log('Permission can be used for spending');}
This helper method queries the blockchain to retrieve real-time information
about a spend permission, including how much can still be spent in the current
period, when the next period starts, and whether the permission is still active.The function automatically uses the appropriate blockchain client based on the
permission’s chain ID and calls multiple view functions on the SpendPermissionManager
contract to gather comprehensive status information.
Parameters
SpendPermission
required
The spend permission object to check status for. This should be a SpendPermission object returned from requestSpendPermission or fetched via fetchPermissions.
Show SpendPermission Properties
string
Deterministic EIP-712 hash of the permission.
string
Signature for the EIP-712 payload.
number
Target chain ID.
object
Underlying permission fields.
Show Permission Fields
address
address
address
bigint
number
Duration in seconds.
number
Unix timestamp (seconds).
number
Unix timestamp (seconds).
string
string
Returns
GetPermissionStatusResponseType
A promise that resolves to an object containing permission status details.
Show GetPermissionStatusResponseType Properties
bigint
Remaining allowance in wei for the current period. Calculated as the difference between the allowance and the amount already spent in the current period.
Date
When the next allowance period begins. This is calculated as one second after the current period ends.
boolean
True if the permission has been revoked on-chain.
boolean
True if the current timestamp is past the permission’s end time.
boolean
True if the permission is not revoked and not expired. A permission is active when it can still be used for spending.
object
Information about the current spending period.
Show currentPeriod Properties
number
Unix timestamp (seconds) when the current period started.
number
Unix timestamp (seconds) when the current period ends.
bigint
Amount already spent in the current period (in wei).
import { getPermissionStatus } from "@base-org/account/spend-permission";// Check the status of a permission (no client needed)const status = await getPermissionStatus(permission);console.log(`Remaining spend: ${status.remainingSpend} wei`);console.log(`Next period starts: ${status.nextPeriodStart}`);console.log(`Is revoked: ${status.isRevoked}`);console.log(`Is expired: ${status.isExpired}`);console.log(`Is active: ${status.isActive}`);if (status.isActive && status.remainingSpend > BigInt(0)) { console.log('Permission can be used for spending');}