> For the complete documentation index, see [llms.txt](/llms.txt).

# Multichain API

The Multichain API is a standard wallet API that supports simultaneous interactions across multiple blockchain networks and ecosystems, as defined in [CAIP-25](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md).

SDK methods vs. Multichain API

MetaMask Connect Multichain exposes [high-level SDK methods](/metamask-connect/multichain/reference/methods/) that wrap the standard Multichain API. Use those methods if you're building with the multichain client.

The standard Multichain API is client-agnostic, and is not entirely exposed by MetaMask Connect Multichain. Use the standard methods referenced on this page if you're building your own client or need lower-level control.

note

MetaMask implements an older version of the [CAIP-25](https://github.com/ChainAgnostic/CAIPs/blob/899779996e8c30ec9c189ff49737704150606f31/CAIPs/caip-25.md) Multichain API specification.

## Methods[​](#methods "Direct link to Methods")

### `wallet_createSession`[​](#wallet%5Fcreatesession "Direct link to wallet_createsession")

Creates a multichain session with a wallet, authorizing that wallet with the specified set of scopes and properties. This method is defined in [CAIP-25](https://github.com/ChainAgnostic/CAIPs/blob/899779996e8c30ec9c189ff49737704150606f31/CAIPs/caip-25.md).

#### Parameters[​](#parameters "Direct link to Parameters")

- `optionalScopes`: `object` - (Optional) [CAIP-217](https://standards.chainagnostic.org/CAIPs/caip-217) authorization scopes the wallet can support for use with this dapp. If scopes are specified, only the following properties are supported:

  - `references`: `array` - (Optional) A list of references to specific blockchains for the namespace of this scope. This property can only be used if the scope namespace does not already specify the blockchain. For example, use this property for an `"eip155"` scope, but not an `"eip155:10"` scope.  
  References are mainly used when there would otherwise be duplicate scopes.
  - `methods`: `array` - A list of JSON-RPC methods the wallet must support to be compatible with the dapp.
  - `notifications`: `array` - A list of JSON-RPC notifications the wallet must support to be compatible with the dapp.
  - `accounts`: `array` - (Optional) A list of [CAIP-10](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md)account IDs valid within this scope. Dapps should include this only if they know which accounts they want the user to permit. When supplied, these accounts are preselected by default in the account selection process. Dapps typically omit this property for the user to select their own accounts.
- `sessionProperties`: `object` - (Optional) Properties that the wallet can use to determine if the session is valid.
- `requiredScopes`: `object` - (Optional) [CAIP-217](https://standards.chainagnostic.org/CAIPs/caip-217) authorization scopes the wallet must support to be compatible with the dapp. We don't recommend using `requiredScopes` with MetaMask. MetaMask treats all `requiredScopes` as `optionalScopes`.

#### Returns[​](#returns "Direct link to Returns")

The scopes and properties of the created session.

#### Example[​](#example "Direct link to Example")

- Request
- Result

```
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "wallet_createSession",
  "params": {
    "optionalScopes": {
      "eip155": {
        "methods": [
          "eth_sendTransaction",
          "eth_signTransaction",
          "eth_sign",
          "eth_subscribe",
          "get_balance",
          "personal_sign"
        ],
        "notifications": ["eth_subscription"]
      },
      "eip155:10": {
        "methods": ["get_balance"],
        "notifications": []
      },
      "eip155:42161": {
        "methods": ["eth_sendTransaction", "eth_signTransaction", "get_balance", "personal_sign"],
        "notifications": []
      }
    }
  }
}

```

```
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "sessionScopes": {
      "eip155": {
        "references": ["1", "137"],
        "methods": [
          "eth_sendTransaction",
          "eth_signTransaction",
          "eth_subscribe",
          "get_balance",
          "eth_sign",
          "personal_sign"
        ],
        "notifications": ["eth_subscription"],
        "accounts": [
          "eip155:1:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb",
          "eip155:137:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb"
        ]
      },
      "eip155:10": {
        "methods": ["get_balance"],
        "notifications": [],
        "accounts": []
      },
      "eip155:42161": {
        "methods": ["personal_sign"],
        "notifications": [],
        "accounts": ["eip155:42161:0x0910e12C68d02B561a34569E1367c9AAb42bd810"]
      }
    },
    "sessionProperties": {
      "expiry": "2022-11-30T17:07:31+00:00",
      "globalConfig": {
        "foo": "bar"
      }
    }
  }
}

```

### `wallet_getSession`[​](#wallet%5Fgetsession "Direct link to wallet_getsession")

Gets the scopes and properties within the active session. This method is defined in [CAIP-312](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-312.md).

note

MetaMask doesn't support session IDs.

#### Parameters[​](#parameters-1 "Direct link to Parameters")

None.

#### Returns[​](#returns-1 "Direct link to Returns")

The scopes and properties of the session.

#### Example[​](#example-1 "Direct link to Example")

- Request
- Result

```
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "wallet_getSession",
  "params": {}
}

```

```
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "sessionScopes": {
      "eip155:1": {
        "methods": ["eth_signTransaction"],
        "notifications": [],
        "accounts": ["eip155:1:0xabc123"]
      },
      "eip155:137": {
        "methods": ["eth_sendTransaction"],
        "notifications": [],
        "accounts": ["eip155:137:0xdef456"]
      },
      "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1": {
        "methods": ["getBalance", "getAccountInfo", "sendTransaction", "getBlock"],
        "notifications": [],
        "accounts": [
          "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1:4Nd1mS8AUwK3kU3gdiAM6QCvqhA7Do8rKtMXsGyqrJxy"
        ]
      }
    }
  }
}

```

### `wallet_invokeMethod`[​](#wallet%5Finvokemethod "Direct link to wallet_invokemethod")

Invokes the specified JSON-RPC API method on the specified network previously authorized to the dapp within a session. This method is defined in [CAIP-27](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-27.md).

note

MetaMask doesn't support session IDs.

#### Parameters[​](#parameters-2 "Direct link to Parameters")

- `scope`: `string` - A [CAIP-2](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md)chain ID previously authorized to the dapp within a session.
- `request`: `object` - A request object containing:  
  - `method`: `string` - The JSON-RPC API method to invoke, previously authorized to the dapp within a session.
  - `params`: `object` - The RPC method parameters (can be empty).

#### Returns[​](#returns-2 "Direct link to Returns")

The response from the JSON-RPC method call.

#### Example[​](#example-2 "Direct link to Example")

- Request
- Result

```
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "wallet_invokeMethod",
  "params": {
    "scope": "eip155:1",
    "request": {
      "method": "eth_sendTransaction",
      "params": [
        {
          "to": "0x4B0897b0513FdBeEc7C469D9aF4fA6C0752aBea7",
          "from": "0xDeaDbeefdEAdbeefdEadbEEFdeadbeefDEADbEEF",
          "gas": "0x76c0",
          "value": "0x8ac7230489e80000",
          "data": "0x",
          "gasPrice": "0x4a817c800"
        }
      ]
    }
  }
}

```

```
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "scope": "eip155:1",
    "result": {
      "method": "eth_sendTransaction",
      "result": "0x4e306b5a5a37532e1734503f7d2427a86f2c992fbe471f5be403b9f734e667c8"
    }
  }
}

```

### `wallet_revokeSession`[​](#wallet%5Frevokesession "Direct link to wallet_revokesession")

Revokes the active session. This method is defined in [CAIP-285](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-285.md).

note

MetaMask doesn't support session IDs.

#### Parameters[​](#parameters-3 "Direct link to Parameters")

None.

#### Returns[​](#returns-3 "Direct link to Returns")

`true` if the revocation was successful.

#### Example[​](#example-3 "Direct link to Example")

- Request
- Result

```
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "wallet_revokeSession",
  "params": {}
}

```

```
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": true
}

```

## Events[​](#events "Direct link to Events")

The Multichain API provides the following events that wallets can send to dapps to notify them of changes to a session.

### `wallet_notify`[​](#wallet%5Fnotify "Direct link to wallet_notify")

Notifies the dapp of events or state changes related to a specific, previously authorized network. [CAIP-319](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-319.md) defines this event.

note

MetaMask doesn't support session IDs.

#### Parameters[​](#parameters-4 "Direct link to Parameters")

- `scope`: `string` - A [CAIP-2](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md)chain ID previously authorized to the dapp within a session.
- `notification`: `object` - A notification object containing:  
  - `method`: `string` - A JSON-RPC API notification method name previously authorized to the dapp within a session.
  - `params`: `object` - The RPC notification method parameters.

#### Example[​](#example-4 "Direct link to Example")

```
{
  "jsonrpc": "2.0",
  "method": "wallet_notify",
  "params": {
    "scope": "eip155:1",
    "notification": {
      "method": "eth_subscription",
      "params": {
        "subscription": "0x12345678",
        "result": {
          "blockNumber": "0x1234",
          "transactionHash": "0x5678",
          "logIndex": "0x9abc"
        }
      }
    }
  }
}

```

### `wallet_sessionChanged`[​](#wallet%5Fsessionchanged "Direct link to wallet_sessionchanged")

Notifies the dapp of updates to the active session's authorization scopes. [CAIP-311](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-311.md) defines this method.

note

MetaMask doesn't support session IDs.

#### Parameters[​](#parameters-5 "Direct link to Parameters")

`sessionScopes`: `object` - An object containing the full updated authorization scopes, each formatted according to [CAIP-217](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-217.md).

#### Example[​](#example-5 "Direct link to Example")

```
{
  "jsonrpc": "2.0",
  "method": "wallet_sessionChanged",
  "params": {
    "sessionScopes": {
      "eip155:1": {
        "methods": ["eth_signTransaction", "eth_sendTransaction"],
        "notifications": [],
        "accounts": ["eip155:1:0xabc123"]
      },
      "eip155:137": {
        "methods": ["eth_sendTransaction"],
        "notifications": [],
        "accounts": ["eip155:137:0xdef456"]
      }
    }
  }
}

```

## Next steps[​](#next-steps "Direct link to Next steps")

- Follow the [JavaScript quickstart](/metamask-connect/multichain/quickstart/javascript/) to set up MetaMask Connect Multichain in a dapp.
- See the [MetaMask Connect Multichain methods](/metamask-connect/multichain/reference/methods/) for the client-level methods that wrap this API.
- Understand [scopes](/metamask-connect/multichain/concepts/scopes/), [accounts](/metamask-connect/multichain/concepts/accounts/), and [sessions](/metamask-connect/multichain/concepts/sessions/) for CAIP-2, CAIP-10, and CAIP-25 identifiers.
- See [Send transactions on EVM and Solana](/metamask-connect/multichain/guides/send-transactions/) for practical usage examples.
