Defined in the Base Account SDK
Returns permissions for a user’s Base Account on a specific chain. If a spender
is provided, returns only permissions for that spender. Otherwise, returns all permissions for the account.
Parameters
User’s Base Account address to query.
Optional. Spender address you intend to use for spending. If not provided, returns all permissions for the account.
Optional. EIP-1193 compliant Ethereum provider instance. Get this from sdk.getProvider()
. If not provided, uses the default SDK provider.
Returns
Array of spend permissions matching the query. Show SpendPermission properties
Deterministic EIP-712 hash of the permission.
Signature for the EIP-712 payload.
Underlying permission fields. Unix timestamp (seconds).
Unix timestamp (seconds).
Fetch permissions for specific spender
import { fetchPermissions } from "@base-org/account/spend-permission" ;
import { createBaseAccountSDK } from "@base-org/account" ;
const sdk = createBaseAccountSDK ({
appName: 'My App' ,
appLogoUrl: 'https://example.com/logo.png' ,
appChainIds: [ 84532 ],
});
// Fetch permissions for a specific spender
const permissions = await fetchPermissions ({
account: "0xUserBaseAccountAddress" ,
chainId: 84532 ,
spender: "0xAppSpenderAddress" ,
provider: sdk . getProvider (),
});
// Fetch all permissions for the account (omitting spender)
const allPermissions = await fetchPermissions ({
account: "0xUserBaseAccountAddress" ,
chainId: 84532 ,
});
Error Handling
Always wrap the call in a try-catch block to handle these errors gracefully.