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 the private key of an account managed by the Snap. A Snap might choose to not support this method.
Parameters
An object containing:
id
:string
- ID of the account to be exported (UUIDv4).
Returns
An object containing:
privateKey
:string
- The account's private key.
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
Returns
An array of pending request objects.
Example
- Request
- Response
{
"method": "keyring_listRequests"
}
[
{
"account": "0xd1f5279be4b4dd94133a23dee1b23f5bfc0db1d0",
"id": "f84d3a97-b6e1-47ea-8b0c-fd8609efaad4",
"request": {
"method": "personal_sign",
"params": [
"0x4578616d706c652060706572736f6e616c5f7369676e60206d657373616765",
"0xe887f3b50232722e6eb4c1d3a03b34c9b345acd1"
]
},
"scope": "eip155:1"
},
{
"account": "0xe887f3b50232722e6eb4c1d3a03b34c9b345acd1",
"id": "f6f302ae-38d7-4b95-ae88-bf2fb7fbee87",
"request": {
"method": "eth_sendTransaction",
"params": [
{
"from": "0xe887f3b50232722e6eb4c1d3a03b34c9b345acd1",
"nonce": "0x1",
"gasPrice": "0x10",
"gasLimit": "0x5208",
"to": "0x84674cffb6146d19b986fc88ec70a441b570a45b",
"value": "0x10000",
"data": "0x"
}
]
},
"scope": "eip155:1"
}
]
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
- Request
- Response
{
"method": "keyring_rejectRequest",
"params": {
"id": "f84d3a97-b6e1-47ea-8b0c-fd8609efaad4"
}
}
null
keyring_submitRequest
Submits a new request.
Parameters
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
- Request
- Response
{
"method": "keyring_submitRequest",
"params": {
"address": "0xd1f5279be4b4dd94133a23dee1b23f5bfc0db1d0",
"id": "f84d3a97-b6e1-47ea-8b0c-fd8609efaad4",
"request": {
"method": "personal_sign",
"params": [
"0x4578616d706c652060706572736f6e616c5f7369676e60206d657373616765",
"0xe887f3b50232722e6eb4c1d3a03b34c9b345acd1"
]
},
"scope": "eip155:1"
}
}
{
"pending": false,
"result": "0x9aef363b17bc18dfbdcb9ed3ce5f9f96788ce84b353d262099e90c4fa0b513a4e21ee47bafa04c0630750e901b62bd4839b45219c191ec6076d6549637cb1beb4c"
}