On this page
wallet_getPermissions
Returns the current permissions granted to the dApp. This method does not prompt the user.
Parameters
None
Returns
Array of permission objects:
| Field | Type | Description |
|---|---|---|
parentCapability | string | The permission name |
date | number | Timestamp when granted |
caveats | array | Restrictions on the permission |
Example
const permissions = await window.$onekey.ethereum.request({
method: 'wallet_getPermissions'
})
console.log('Current permissions:', permissions)
// Check if connected
const isConnected = permissions.some(
p => p.parentCapability === 'eth_accounts'
)
console.log('Is connected:', isConnected)Permission Check Utility
async function checkPermissions() {
const permissions = await window.$onekey.ethereum.request({
method: 'wallet_getPermissions'
})
return {
hasAccounts: permissions.some(p => p.parentCapability === 'eth_accounts'),
permissions
}
}
const { hasAccounts } = await checkPermissions()
if (!hasAccounts) {
// Request connection
await window.$onekey.ethereum.request({
method: 'eth_requestAccounts'
})
}Errors
| Code | Message | Description |
|---|---|---|
| -32603 | Internal error | Provider error |
Notes
- Returns an empty array if no permissions are granted
- Does not prompt the user for any action
- Useful for checking connection state without triggering a prompt
- Specified by EIP-2255
Handle unsupported-method errors in the target wallet version. Account permission is distinct from RPC connectivity and does not pre-approve signatures or transactions. For basic connection, use eth_requestAccounts.
Last updated on