Skip to main content

Account Management API

Dapps can communicate with account management Snaps using the Account Management API. The dapp must be allowed to call each method.

Account methods

The following methods are exposed by the Snap for account management.

keyring_createAccount

Creates a new account.

Parameters

An object containing:

  • options: Record<string, Json> - Snap-defined account options.

Returns

An account object.

Example

{
"method": "keyring_createAccount",
"params": {
"options": {
"signerCount": 5,
"threshold": 3
}
}
}

keyring_deleteAccount

Deletes an existing account.

Parameters

An object containing:

  • id: string - ID of the account to be deleted (UUIDv4).

Returns

null

Example

{
"method": "keyring_deleteAccount",
"params": {
"id": "091bbc2e-6625-44d0-ac5c-658670ca649a"
}
}

keyring_exportAccount

Exports account data managed by the Snap. This might include the public key, address, or derivation path. The exact data exported depends on the Snap's implementation and security considerations. A Snap might choose to not support this method or limit the data it exports.

warning

This method can export private keys or any other sensitive data.

Parameters

An object containing:

  • id: string - ID of the account to be exported (UUIDv4).

Returns

An object containing the account data.

Example

{
"method": "keyring_exportAccount",
"params": {
"id": "091bbc2e-6625-44d0-ac5c-658670ca649a"
}
}

keyring_filterAccountChains

Filters for blockchain networks that an account can be used on.

Parameters

An object containing:

  • id: string - Account ID (UUIDv4).
  • chains: string[] - List of CAIP-2 chain IDs of blockchain networks to filter.

Returns

An object containing:

  • chains: string[] - List of CAIP-2 chain IDs of blockchain networks that the account can be used on.

Example

{
"method": "keyring_filterAccountChains",
"params": {
"id": "091bbc2e-6625-44d0-ac5c-658670ca649a",
"chains": ["eip155:W", "eip155:X", "eip155:Y", "eip155:Z"]
}
}

keyring_getAccount

Gets an account from an ID.

Parameters

An object containing:

  • id: string - Account ID (UUIDv4).

Returns

An account object.

Example

{
"method": "keyring_getAccount",
"params": {
"id": "091bbc2e-6625-44d0-ac5c-658670ca649a"
}
}

keyring_listAccounts

Lists all accounts handled by the Snap.

Parameters

None

Returns

An array of account objects handled by the Snap.

Example

{
"method": "keyring_listAccounts"
}

keyring_updateAccount

Updates an account.

Parameters

An account object.

Returns

null

Example

{
"method": "keyring_updateAccount",
"params": {
"address": "0xd1f5279be4b4dd94133a23dee1b23f5bfc0db1d0",
"id": "091bbc2e-6625-44d0-ac5c-658670ca649a",
"methods": [
"eth_sign",
"eth_signTransaction",
"eth_signTypedData_v4",
"personal_sign"
],
"options": {
"signerCount": 7,
"threshold": 4
},
"type": "eip155:eoa"
}
}

Request methods

The following methods are exposed by the Snap for managing signature requests.

keyring_approveRequest

Approves a pending request.

Parameters

An object containing:

  • id: string - Request ID.
  • data: Record<string, Json> - Optional Snap-defined arguments.

Returns

null

Example

{
"method": "keyring_approveRequest",
"params": {
"id": "f84d3a97-b6e1-47ea-8b0c-fd8609efaad4"
}
}

keyring_getRequest

Gets a request from an ID.

Parameters

An object containing:

  • id: string - Request ID.

Returns

A request object.

Example

{
"method": "keyring_getRequest",
"params": {
"id": "f84d3a97-b6e1-47ea-8b0c-fd8609efaad4"
}
}

keyring_listRequests

Lists all pending requests.

Parameters

None

Returns

An array of pending request objects.

Example

{
"method": "keyring_listRequests"
}

keyring_rejectRequest

Rejects a pending request and removes it from the list of pending requests.

Parameters

An object containing:

  • id: string - Request ID.

Returns

null

Example

{
"method": "keyring_rejectRequest",
"params": {
"id": "f84d3a97-b6e1-47ea-8b0c-fd8609efaad4"
}
}

keyring_submitRequest

Submits a new request.

Parameters

A request object.

Returns

If the request is synchronous, keyring_submitRequest returns an object containing:

  • pending - false to indicate a synchronous request.
  • result: Json - Request result.

If the request is asynchronous, keyring_submitRequest returns an object containing:

  • pending - true to indicate that the request will be handled asynchronously.
  • redirect - An optional redirect object containing:
    • message: string - Redirect message.
    • url: string - Redirect URL.

Example

{
"method": "keyring_submitRequest",
"params": {
"address": "0xd1f5279be4b4dd94133a23dee1b23f5bfc0db1d0",
"id": "f84d3a97-b6e1-47ea-8b0c-fd8609efaad4",
"request": {
"method": "personal_sign",
"params": [
"0x4578616d706c652060706572736f6e616c5f7369676e60206d657373616765",
"0xe887f3b50232722e6eb4c1d3a03b34c9b345acd1"
]
},
"scope": "eip155:1"
}
}