{
    "openrpc": "1.2.4",
    "info": {
        "title": "MetaMask Multichain API",
        "version": "1.0.0",
        "description": "Specification for the Multichain API layer of MetaMask's Wallet API."
    },
    "methods": [
        {
            "name": "wallet_notify",
            "paramStructure": "by-name",
            "params": [
                {
                    "name": "scope",
                    "description": "A valid `scope` string that has been previously authorized to the dapp.",
                    "required": true,
                    "schema": {
                        "$ref": "#/components/schemas/ScopeString"
                    }
                },
                {
                    "name": "notification",
                    "description": "An object containing a JSON-RPC notification with `method` and `params`.",
                    "deprecated": false,
                    "required": true,
                    "schema": {
                        "type": "object",
                        "properties": {
                            "method": {
                                "type": "string"
                            },
                            "params": true
                        }
                    }
                }
            ]
        },
        {
            "name": "wallet_invokeMethod",
            "paramStructure": "by-name",
            "params": [
                {
                    "name": "scope",
                    "description": "A valid `scope` string that has been previously authorized to the dapp.",
                    "required": true,
                    "schema": {
                        "$ref": "#/components/schemas/ScopeString"
                    }
                },
                {
                    "name": "request",
                    "description": "An object containing a JSON-RPC request with `method` and `params`.",
                    "deprecated": false,
                    "required": true,
                    "schema": {
                        "type": "object",
                        "properties": {
                            "method": {
                                "type": "string"
                            },
                            "params": true
                        }
                    }
                }
            ],
            "result": {
                "name": "wallet_invokeMethodResult",
                "schema": true
            },
            "examples": [
                {
                    "name": "wallet_invokeMethodExample",
                    "params": [
                        {
                            "name": "scope",
                            "value": "eip155:1"
                        },
                        {
                            "name": "request",
                            "value": {
                                "method": "eth_getBalance",
                                "params": []
                            }
                        }
                    ],
                    "result": {
                        "name": "wallet_invokeMethodResult",
                        "value": "0x1"
                    }
                }
            ]
        },
        {
            "name": "wallet_revokeSession",
            "description": "The `wallet_revokeSession` method revokes the entire active session.",
            "params": [],
            "result": {
                "name": "wallet_revokeSessionResult",
                "schema": {
                    "type": "boolean"
                }
            },
            "examples": [
                {
                    "name": "wallet_revokeSessionExample",
                    "params": [],
                    "result": {
                        "name": "wallet_revokeSessionExampleResult",
                        "value": true
                    }
                }
            ],
            "errors": [
                {
                    "$ref": "#/components/errors/UnknownError"
                }
            ]
        },
        {
            "name": "wallet_sessionChanged",
            "paramStructure": "by-name",
            "description": "This notification is published by the wallet to notify the callers of updates to a shared session's authorization scopes. The event payload contains the new `sessionScopes`.",
            "params": [
                {
                    "name": "sessionScopes",
                    "schema": {
                        "$ref": "#/components/schemas/SessionScopes"
                    }
                }
            ],
            "examples": [
                {
                    "name": "wallet_sessionChangedExample",
                    "description": "Example of a wallet_sessionChanged notification.",
                    "params": [
                        {
                            "name": "sessionScopes",
                            "value": {
                                "eip155:1337": {
                                    "accounts": [
                                        "eip155:1337:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
                                    ],
                                    "methods": [
                                        "personal_sign",
                                        "eth_signTypedData_v4",
                                        "wallet_watchAsset",
                                        "eth_sendTransaction",
                                        "eth_decrypt",
                                        "eth_getEncryptionPublicKey",
                                        "web3_clientVersion",
                                        "eth_subscribe",
                                        "eth_unsubscribe",
                                        "wallet_swapAsset",
                                        "eth_blockNumber",
                                        "eth_call",
                                        "eth_chainId",
                                        "eth_estimateGas",
                                        "eth_feeHistory",
                                        "eth_gasPrice",
                                        "eth_getBalance",
                                        "eth_getBlockByHash",
                                        "eth_getBlockByNumber",
                                        "eth_getBlockTransactionCountByHash",
                                        "eth_getBlockTransactionCountByNumber",
                                        "eth_getCode",
                                        "eth_getFilterChanges",
                                        "eth_getFilterLogs",
                                        "eth_getLogs",
                                        "eth_getProof",
                                        "eth_getStorageAt",
                                        "eth_getTransactionByBlockHashAndIndex",
                                        "eth_getTransactionByBlockNumberAndIndex",
                                        "eth_getTransactionByHash",
                                        "eth_getTransactionCount",
                                        "eth_getTransactionReceipt",
                                        "eth_getUncleCountByBlockHash",
                                        "eth_getUncleCountByBlockNumber",
                                        "eth_newBlockFilter",
                                        "eth_newFilter",
                                        "eth_newPendingTransactionFilter",
                                        "eth_sendRawTransaction",
                                        "eth_syncing",
                                        "eth_uninstallFilter"
                                    ],
                                    "notifications": [
                                        "eth_subscription"
                                    ]
                                },
                                "wallet": {
                                    "accounts": [],
                                    "methods": [
                                        "wallet_registerOnboarding",
                                        "wallet_scanQRCode"
                                    ],
                                    "notifications": []
                                },
                                "wallet:eip155": {
                                    "accounts": [
                                        "wallet:eip155:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
                                    ],
                                    "methods": [
                                        "wallet_addEthereumChain"
                                    ],
                                    "notifications": []
                                }
                            }
                        }
                    ]
                }
            ]
        },
        {
            "name": "wallet_getSession",
            "description": "The `wallet_getSession` method returns an active session.",
            "params": [],
            "result": {
                "name": "wallet_getSessionResult",
                "schema": {
                    "type": "object",
                    "properties": {
                        "sessionScopes": {
                            "$ref": "#/components/schemas/SessionScopes"
                        }
                    }
                }
            },
            "examples": [
                {
                    "name": "wallet_getSessionExample",
                    "description": "Example of a getSession request.",
                    "params": [],
                    "result": {
                        "name": "wallet_getSessionResultExample",
                        "value": {
                            "sessionScopes": {
                                "eip155:1337": {
                                    "accounts": [
                                        "eip155:1337:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
                                    ],
                                    "methods": [
                                        "personal_sign",
                                        "eth_signTypedData_v4",
                                        "wallet_watchAsset",
                                        "eth_sendTransaction",
                                        "eth_decrypt",
                                        "eth_getEncryptionPublicKey",
                                        "web3_clientVersion",
                                        "eth_subscribe",
                                        "eth_unsubscribe",
                                        "wallet_swapAsset",
                                        "eth_blockNumber",
                                        "eth_call",
                                        "eth_chainId",
                                        "eth_estimateGas",
                                        "eth_feeHistory",
                                        "eth_gasPrice",
                                        "eth_getBalance",
                                        "eth_getBlockByHash",
                                        "eth_getBlockByNumber",
                                        "eth_getBlockTransactionCountByHash",
                                        "eth_getBlockTransactionCountByNumber",
                                        "eth_getCode",
                                        "eth_getFilterChanges",
                                        "eth_getFilterLogs",
                                        "eth_getLogs",
                                        "eth_getProof",
                                        "eth_getStorageAt",
                                        "eth_getTransactionByBlockHashAndIndex",
                                        "eth_getTransactionByBlockNumberAndIndex",
                                        "eth_getTransactionByHash",
                                        "eth_getTransactionCount",
                                        "eth_getTransactionReceipt",
                                        "eth_getUncleCountByBlockHash",
                                        "eth_getUncleCountByBlockNumber",
                                        "eth_newBlockFilter",
                                        "eth_newFilter",
                                        "eth_newPendingTransactionFilter",
                                        "eth_sendRawTransaction",
                                        "eth_syncing",
                                        "eth_uninstallFilter"
                                    ],
                                    "notifications": [
                                        "eth_subscription"
                                    ]
                                },
                                "wallet": {
                                    "accounts": [],
                                    "methods": [
                                        "wallet_registerOnboarding",
                                        "wallet_scanQRCode"
                                    ],
                                    "notifications": []
                                },
                                "wallet:eip155": {
                                    "accounts": [
                                        "wallet:eip155:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
                                    ],
                                    "methods": [
                                        "wallet_addEthereumChain"
                                    ],
                                    "notifications": []
                                }
                            }
                        }
                    }
                }
            ]
        },
        {
            "name": "wallet_createSession",
            "paramStructure": "by-name",
            "params": [
                {
                    "name": "requiredScopes",
                    "description": "Scopes that the wallet must support in order to be used with this provider.",
                    "schema": {
                        "type": "object",
                        "patternProperties": {
                            "[-a-z0-9]{3,8}(:[-_a-zA-Z0-9]{1,32})?": {
                                "$ref": "#/components/schemas/Scope"
                            }
                        }
                    }
                },
                {
                    "name": "optionalScopes",
                    "description": "Scopes that the wallet may support in order to be used with this provider.",
                    "schema": {
                        "type": "object",
                        "patternProperties": {
                            "[-a-z0-9]{3,8}(:[-_a-zA-Z0-9]{1,32})?": {
                                "$ref": "#/components/schemas/Scope"
                            }
                        }
                    }
                },
                {
                    "name": "sessionProperties",
                    "description": "Properties that the wallet may use to determine if the session is valid.",
                    "schema": {
                        "type": "object"
                    }
                }
            ],
            "result": {
                "name": "wallet_createSessionResult",
                "schema": {
                    "type": "object",
                    "properties": {
                        "sessionScopes": {
                            "$ref": "#/components/schemas/SessionScopes"
                        },
                        "sessionProperties": {
                            "type": "object"
                        }
                    }
                }
            },
            "examples": [
                {
                    "name": "wallet_createSessionEthExample",
                    "description": "Example of a createSession request.",
                    "params": [
                        {
                            "name": "optionalScopes",
                            "value": {
                                "eip155:1337": {
                                    "methods": [
                                        "wallet_watchAsset",
                                        "eth_sendTransaction",
                                        "eth_decrypt",
                                        "eth_getEncryptionPublicKey",
                                        "web3_clientVersion",
                                        "eth_subscribe",
                                        "eth_unsubscribe",
                                        "eth_blockNumber",
                                        "eth_call",
                                        "eth_chainId",
                                        "eth_estimateGas",
                                        "eth_feeHistory",
                                        "eth_gasPrice",
                                        "eth_getBalance",
                                        "eth_getBlockByHash",
                                        "eth_getBlockByNumber",
                                        "eth_getBlockTransactionCountByHash",
                                        "eth_getBlockTransactionCountByNumber",
                                        "eth_getCode",
                                        "eth_getFilterChanges",
                                        "eth_getFilterLogs",
                                        "eth_getLogs",
                                        "eth_getProof",
                                        "eth_getStorageAt",
                                        "eth_getTransactionByBlockHashAndIndex",
                                        "eth_getTransactionByBlockNumberAndIndex",
                                        "eth_getTransactionByHash",
                                        "eth_getTransactionCount",
                                        "eth_getTransactionReceipt",
                                        "eth_getUncleCountByBlockHash",
                                        "eth_getUncleCountByBlockNumber",
                                        "eth_newBlockFilter",
                                        "eth_newFilter",
                                        "eth_newPendingTransactionFilter",
                                        "eth_sendRawTransaction",
                                        "eth_syncing",
                                        "eth_uninstallFilter"
                                    ],
                                    "notifications": [
                                        "eth_subscription"
                                    ]
                                },
                                "wallet": {
                                    "methods": [
                                        "wallet_registerOnboarding",
                                        "wallet_scanQRCode"
                                    ],
                                    "notifications": []
                                },
                                "wallet:eip155": {
                                    "methods": [
                                        "wallet_addEthereumChain"
                                    ],
                                    "notifications": []
                                }
                            }
                        }
                    ],
                    "result": {
                        "name": "wallet_createSessionResultExample",
                        "value": {
                            "sessionProperties": {},
                            "sessionScopes": {
                                "eip155:1337": {
                                    "accounts": [
                                        "eip155:1337:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
                                    ],
                                    "methods": [
                                        "personal_sign",
                                        "eth_signTypedData_v4",
                                        "wallet_watchAsset",
                                        "eth_sendTransaction",
                                        "eth_decrypt",
                                        "eth_getEncryptionPublicKey",
                                        "web3_clientVersion",
                                        "eth_subscribe",
                                        "eth_unsubscribe",
                                        "wallet_swapAsset",
                                        "eth_blockNumber",
                                        "eth_call",
                                        "eth_chainId",
                                        "eth_estimateGas",
                                        "eth_feeHistory",
                                        "eth_gasPrice",
                                        "eth_getBalance",
                                        "eth_getBlockByHash",
                                        "eth_getBlockByNumber",
                                        "eth_getBlockTransactionCountByHash",
                                        "eth_getBlockTransactionCountByNumber",
                                        "eth_getCode",
                                        "eth_getFilterChanges",
                                        "eth_getFilterLogs",
                                        "eth_getLogs",
                                        "eth_getProof",
                                        "eth_getStorageAt",
                                        "eth_getTransactionByBlockHashAndIndex",
                                        "eth_getTransactionByBlockNumberAndIndex",
                                        "eth_getTransactionByHash",
                                        "eth_getTransactionCount",
                                        "eth_getTransactionReceipt",
                                        "eth_getUncleCountByBlockHash",
                                        "eth_getUncleCountByBlockNumber",
                                        "eth_newBlockFilter",
                                        "eth_newFilter",
                                        "eth_newPendingTransactionFilter",
                                        "eth_sendRawTransaction",
                                        "eth_syncing",
                                        "eth_uninstallFilter"
                                    ],
                                    "notifications": [
                                        "eth_subscription"
                                    ]
                                },
                                "wallet": {
                                    "accounts": [],
                                    "methods": [
                                        "wallet_registerOnboarding",
                                        "wallet_scanQRCode"
                                    ],
                                    "notifications": []
                                },
                                "wallet:eip155": {
                                    "accounts": [
                                        "wallet:eip155:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
                                    ],
                                    "methods": [
                                        "wallet_addEthereumChain"
                                    ],
                                    "notifications": []
                                }
                            }
                        }
                    }
                },
                {
                    "name": "wallet_createSessionEthUnsupportedMethodsExample",
                    "description": "Example of a createSession request with unsupported eip155 methods.",
                    "params": [
                        {
                            "name": "optionalScopes",
                            "value": {
                                "eip155:1337": {
                                    "methods": [
                                        "not_supported"
                                    ],
                                    "notifications": []
                                },
                                "wallet": {
                                    "methods": [],
                                    "notifications": []
                                },
                                "wallet:eip155": {
                                    "methods": [],
                                    "notifications": []
                                }
                            }
                        }
                    ],
                    "result": {
                        "name": "wallet_createSessionEthUnsupportedMethodsResultExample",
                        "value": {
                            "sessionProperties": {},
                            "sessionScopes": {
                                "eip155:1337": {
                                    "accounts": [
                                        "eip155:1337:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
                                    ],
                                    "methods": [
                                        "personal_sign",
                                        "eth_signTypedData_v4",
                                        "wallet_watchAsset",
                                        "eth_sendTransaction",
                                        "eth_decrypt",
                                        "eth_getEncryptionPublicKey",
                                        "web3_clientVersion",
                                        "eth_subscribe",
                                        "eth_unsubscribe",
                                        "wallet_swapAsset",
                                        "eth_blockNumber",
                                        "eth_call",
                                        "eth_chainId",
                                        "eth_estimateGas",
                                        "eth_feeHistory",
                                        "eth_gasPrice",
                                        "eth_getBalance",
                                        "eth_getBlockByHash",
                                        "eth_getBlockByNumber",
                                        "eth_getBlockTransactionCountByHash",
                                        "eth_getBlockTransactionCountByNumber",
                                        "eth_getCode",
                                        "eth_getFilterChanges",
                                        "eth_getFilterLogs",
                                        "eth_getLogs",
                                        "eth_getProof",
                                        "eth_getStorageAt",
                                        "eth_getTransactionByBlockHashAndIndex",
                                        "eth_getTransactionByBlockNumberAndIndex",
                                        "eth_getTransactionByHash",
                                        "eth_getTransactionCount",
                                        "eth_getTransactionReceipt",
                                        "eth_getUncleCountByBlockHash",
                                        "eth_getUncleCountByBlockNumber",
                                        "eth_newBlockFilter",
                                        "eth_newFilter",
                                        "eth_newPendingTransactionFilter",
                                        "eth_sendRawTransaction",
                                        "eth_syncing",
                                        "eth_uninstallFilter"
                                    ],
                                    "notifications": [
                                        "eth_subscription"
                                    ]
                                },
                                "wallet": {
                                    "accounts": [],
                                    "methods": [
                                        "wallet_registerOnboarding",
                                        "wallet_scanQRCode"
                                    ],
                                    "notifications": []
                                },
                                "wallet:eip155": {
                                    "accounts": [
                                        "wallet:eip155:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
                                    ],
                                    "methods": [
                                        "wallet_addEthereumChain"
                                    ],
                                    "notifications": []
                                }
                            }
                        }
                    }
                },
                {
                    "name": "wallet_createSessionUnsupportedScopesExample",
                    "description": "Example of a createSession request with unsupported scopes.",
                    "params": [
                        {
                            "name": "optionalScopes",
                            "value": {
                                "foobar": {
                                    "methods": [
                                        "eth_getBalance"
                                    ],
                                    "notifications": [
                                        "eth_subscription"
                                    ]
                                },
                                "eip155:1": {
                                    "accounts": [
                                        "eip155:1:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
                                    ],
                                    "methods": [
                                        "personal_sign",
                                        "eth_signTypedData_v4",
                                        "wallet_watchAsset",
                                        "eth_sendTransaction",
                                        "eth_decrypt",
                                        "eth_getEncryptionPublicKey",
                                        "web3_clientVersion",
                                        "eth_subscribe",
                                        "eth_unsubscribe",
                                        "wallet_swapAsset",
                                        "eth_blockNumber",
                                        "eth_call",
                                        "eth_chainId",
                                        "eth_estimateGas",
                                        "eth_feeHistory",
                                        "eth_gasPrice",
                                        "eth_getBalance",
                                        "eth_getBlockByHash",
                                        "eth_getBlockByNumber",
                                        "eth_getBlockTransactionCountByHash",
                                        "eth_getBlockTransactionCountByNumber",
                                        "eth_getCode",
                                        "eth_getFilterChanges",
                                        "eth_getFilterLogs",
                                        "eth_getLogs",
                                        "eth_getProof",
                                        "eth_getStorageAt",
                                        "eth_getTransactionByBlockHashAndIndex",
                                        "eth_getTransactionByBlockNumberAndIndex",
                                        "eth_getTransactionByHash",
                                        "eth_getTransactionCount",
                                        "eth_getTransactionReceipt",
                                        "eth_getUncleCountByBlockHash",
                                        "eth_getUncleCountByBlockNumber",
                                        "eth_newBlockFilter",
                                        "eth_newFilter",
                                        "eth_newPendingTransactionFilter",
                                        "eth_sendRawTransaction",
                                        "eth_syncing",
                                        "eth_uninstallFilter"
                                    ],
                                    "notifications": [
                                        "eth_subscription"
                                    ]
                                }
                            }
                        }
                    ],
                    "result": {
                        "name": "wallet_createSessionUnsupportedScopesResultExample",
                        "value": {
                            "sessionProperties": {},
                            "sessionScopes": {
                                "eip155:1": {
                                    "accounts": [
                                        "eip155:1:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
                                    ],
                                    "methods": [
                                        "personal_sign",
                                        "eth_signTypedData_v4",
                                        "wallet_watchAsset",
                                        "eth_sendTransaction",
                                        "eth_decrypt",
                                        "eth_getEncryptionPublicKey",
                                        "web3_clientVersion",
                                        "eth_subscribe",
                                        "eth_unsubscribe",
                                        "wallet_swapAsset",
                                        "eth_blockNumber",
                                        "eth_call",
                                        "eth_chainId",
                                        "eth_estimateGas",
                                        "eth_feeHistory",
                                        "eth_gasPrice",
                                        "eth_getBalance",
                                        "eth_getBlockByHash",
                                        "eth_getBlockByNumber",
                                        "eth_getBlockTransactionCountByHash",
                                        "eth_getBlockTransactionCountByNumber",
                                        "eth_getCode",
                                        "eth_getFilterChanges",
                                        "eth_getFilterLogs",
                                        "eth_getLogs",
                                        "eth_getProof",
                                        "eth_getStorageAt",
                                        "eth_getTransactionByBlockHashAndIndex",
                                        "eth_getTransactionByBlockNumberAndIndex",
                                        "eth_getTransactionByHash",
                                        "eth_getTransactionCount",
                                        "eth_getTransactionReceipt",
                                        "eth_getUncleCountByBlockHash",
                                        "eth_getUncleCountByBlockNumber",
                                        "eth_newBlockFilter",
                                        "eth_newFilter",
                                        "eth_newPendingTransactionFilter",
                                        "eth_sendRawTransaction",
                                        "eth_syncing",
                                        "eth_uninstallFilter"
                                    ],
                                    "notifications": [
                                        "eth_subscription"
                                    ]
                                }
                            }
                        }
                    }
                }
            ],
            "errors": [
                {
                    "$ref": "#/components/errors/UnknownError"
                },
                {
                    "code": 5100,
                    "message": "Requested networks are not supported"
                },
                {
                    "code": 5101,
                    "message": "Requested methods are not supported"
                },
                {
                    "code": 5102,
                    "message": "Requested notifications are not supported"
                },
                {
                    "code": 5300,
                    "message": "Invalid scopedProperties requested"
                },
                {
                    "code": 5301,
                    "message": "scopedProperties can only be outside of sessionScopes"
                },
                {
                    "code": 5302,
                    "message": "Invalid sessionProperties requested"
                }
            ]
        }
    ],
    "components": {
        "errors": {
            "UnknownError": {
                "code": 5000,
                "message": "Unknown error with request"
            }
        },
        "schemas": {
            "SessionScopes": {
                "type": "object",
                "patternProperties": {
                    "[-a-z0-9]{3,8}(:[-_a-zA-Z0-9]{1,32})?": {
                        "$ref": "#/components/schemas/Scope"
                    }
                }
            },
            "ScopeString": {
                "type": "string",
                "pattern": "[-a-z0-9]{3,8}(:[-_a-zA-Z0-9]{1,32})?"
            },
            "Scope": {
                "type": "object",
                "title": "Scope",
                "description": "Scope for a multichain connection.",
                "additionalProperties": true,
                "required": [
                    "notifications",
                    "methods"
                ],
                "properties": {
                    "references": {
                        "description": "References to specific blockchains associated with this scope. Primarily used for shorthand when there would otherwise be duplicate scopes. Supported only in requests.",
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "methods": {
                        "description": "Methods associated with this scope. Supported in both requests and responses.",
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "notifications": {
                        "description": "Notifications associated with this scope. Supported in both requests and responses.",
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "accounts": {
                        "type": "array",
                        "description": "Account associated with this scope. Supported in both requests and responses.",
                        "items": {
                            "type": "string"
                        }
                    }
                }
            }
        }
    }
}
