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
Example
- Request
- Response
{
"method": "keyring_createAccount",
"params": {
"options": {
"signerCount": 5,
"threshold": 3
}
}
}
{
"address": "0xd1f5279be4b4dd94133a23dee1b23f5bfc0db1d0",
"id": "091bbc2e-6625-44d0-ac5c-658670ca649a",
"methods": [
"eth_sign",
"eth_signTransaction",
"eth_signTypedData_v4",
"personal_sign"
],
"options": {
"signerCount": 5,
"threshold": 3
},
"type": "eip155:eoa"
}
keyring_deleteAccount
Deletes an existing account.
Parameters
An object containing:
id
:string
- ID of the account to be deleted (UUIDv4).
Returns
null
Example
- Request
- Response
{
"method": "keyring_deleteAccount",
"params": {
"id": "091bbc2e-6625-44d0-ac5c-658670ca649a"
}
}
null
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.
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
- Request
- Response
{
"method": "keyring_exportAccount",
"params": {
"id": "091bbc2e-6625-44d0-ac5c-658670ca649a"
}
}
{
"privateKey": "66a41d66be6483f1fdfd01fdb66173d449594bbd286149b019504dd72b58bc51"
}
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
- Request
- Response
{
"method": "keyring_filterAccountChains",
"params": {
"id": "091bbc2e-6625-44d0-ac5c-658670ca649a",
"chains": ["eip155:W", "eip155:X", "eip155:Y", "eip155:Z"]
}
}
{
"chains": ["eip155:X", "eip155:Y"]
}
keyring_getAccount
Gets an account from an ID.
Parameters
An object containing:
id
:string
- Account ID (UUIDv4).
Returns
Example
- Request
- Response
{
"method": "keyring_getAccount",
"params": {
"id": "091bbc2e-6625-44d0-ac5c-658670ca649a"
}
}
{
"address": "0xd1f5279be4b4dd94133a23dee1b23f5bfc0db1d0",
"id": "091bbc2e-6625-44d0-ac5c-658670ca649a",
"methods": [
"eth_sign",
"eth_signTransaction",
"eth_signTypedData_v4",
"personal_sign"
],
"options": {
"signerCount": 5,
"threshold": 3
},
"type": "eip155:eoa"
}
keyring_listAccounts
Lists all accounts handled by the Snap.
Parameters
None
Returns
An array of account objects handled by the Snap.
Example
- Request
- Response
{
"method": "keyring_listAccounts"
}
[
{
"address": "0xd1f5279be4b4dd94133a23dee1b23f5bfc0db1d0",
"id": "091bbc2e-6625-44d0-ac5c-658670ca649a",
"methods": [
"eth_sign",
"eth_signTransaction",
"eth_signTypedData_v4",
"personal_sign"
],
"options": {
"signerCount": 5,
"threshold": 3
},
"type": "eip155:eoa"
},
{
"address": "0x84674cffb6146d19b986fc88ec70a441b570a45b",
"id": "17a87b4a-286c-444d-aebb-1fed89021419",
"methods": [
"eth_prepareUserOperation",
"eth_patchUserOperation",
"eth_signUserOperation"
],
"type": "eip155:erc4337"
}
]
keyring_updateAccount
Updates an account.
Parameters
Returns
null
Example
- Request
- Response
{
"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"
}
}
null
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
- Request
- Response
{
"method": "keyring_approveRequest",
"params": {
"id": "f84d3a97-b6e1-47ea-8b0c-fd8609efaad4"
}
}
null
keyring_getRequest
Gets a request from an ID.
Parameters
An object containing:
id
:string
- Request ID.
Returns
Example
- Request
- Response
{
"method": "keyring_getRequest",
"params": {
"id": "f84d3a97-b6e1-47ea-8b0c-fd8609efaad4"
}
}
{
"address": "0xd1f5279be4b4dd94133a23dee1b23f5bfc0db1d0",
"id": "f84d3a97-b6e1-47ea-8b0c-fd8609efaad4",
"request": {
"method": "personal_sign",
"params": [
"0x4578616d706c652060706572736f6e616c5f7369676e60206d657373616765",
"0xe887f3b50232722e6eb4c1d3a03b34c9b345acd1"
]
},
"scope": "eip155:1"
}
keyring_listRequests
Lists all pending requests.
Parameters
None