sidebar_position | tags | |
---|---|---|
1 |
|
import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem";
Dapps can communicate with account management Snaps using the Account Management API. The dapp must be allowed to call each method.
The following methods are exposed by the Snap for account management.
Creates a new account.
An object containing:
options
:Record<string, Json>
- Snap-defined account options.
{
"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"
}
Deletes an existing account.
An object containing:
id
:string
- ID of the account to be deleted (UUIDv4).
null
{
"method": "keyring_deleteAccount",
"params": {
"id": "091bbc2e-6625-44d0-ac5c-658670ca649a"
}
}
null
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.
:::
An object containing:
id
:string
- ID of the account to be exported (UUIDv4).
An object containing the account data.
{
"method": "keyring_exportAccount",
"params": {
"id": "091bbc2e-6625-44d0-ac5c-658670ca649a"
}
}
{
"privateKey": "66a41d66be6483f1fdfd01fdb66173d449594bbd286149b019504dd72b58bc51"
}
Filters for blockchain networks that an account can be used on.
An object containing:
id
:string
- Account ID (UUIDv4).chains
:string[]
- List of CAIP-2 chain IDs of blockchain networks to filter.
An object containing:
chains
:string[]
- List of CAIP-2 chain IDs of blockchain networks that the account can be used on.
{
"method": "keyring_filterAccountChains",
"params": {
"id": "091bbc2e-6625-44d0-ac5c-658670ca649a",
"chains": ["eip155:W", "eip155:X", "eip155:Y", "eip155:Z"]
}
}
{
"chains": ["eip155:X", "eip155:Y"]
}
Gets an account from an ID.
An object containing:
id
:string
- Account ID (UUIDv4).
{
"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"
}
Lists all accounts handled by the Snap.
None
An array of account objects handled by the Snap.
{
"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"
}
]
Updates an account.
null
{
"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
The following methods are exposed by the Snap for managing signature requests.
Approves a pending request.
An object containing:
id
:string
- Request ID.data
:Record<string, Json>
- Optional Snap-defined arguments.
null
{
"method": "keyring_approveRequest",
"params": {
"id": "f84d3a97-b6e1-47ea-8b0c-fd8609efaad4"
}
}
null
Gets a request from an ID.
An object containing:
id
:string
- Request ID.
{
"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"
}
Lists all pending requests.
None
An array of pending request objects.
{
"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"
}
]
Rejects a pending request and removes it from the list of pending requests.
An object containing:
id
:string
- Request ID.
null
{
"method": "keyring_rejectRequest",
"params": {
"id": "f84d3a97-b6e1-47ea-8b0c-fd8609efaad4"
}
}
null
Submits a new request.
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.
{
"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"
}