| description | Configuration options reference for MetaMask SDK. |
|---|
import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem";
MetaMask SDK takes the following configuration options.
checkInstallationImmediately: <boolean>checkInstallationImmediately: trueEnables or disables immediately checking if MetaMask is installed on the user's browser.
If true, the SDK checks for installation upon page load and sends a connection request, prompting
the user to install MetaMask if it's not already installed.
If false, the SDK waits for the connect method to be called to check for installation.
The default is false.
checkInstallationOnAllCalls: <boolean>checkInstallationOnAllCalls: trueEnables or disables checking if MetaMask is installed on the user's browser before each RPC request.
The default is false.
communicationServerUrl: <string>communicationServerUrl: "https://metamask-sdk-socket.metafi.codefi.network/"The URL of the communication server to use. This option is mainly used for debugging and testing the SDK.
dappMetadata: {
name: <string>,
url: <string>,
iconUrl: <string>,
}dappMetadata: {
name: "My Dapp",
url: "https://mydapp.com",
iconUrl: "https://mydapp.com/icon.png",
}Metadata about the dapp using the SDK. The metadata options are:
name- Name of the dappurl- URL of the dappiconUrl- URL of the dapp's icon
:::tip important
Setting dappMetaData creates a clear and trustworthy user experience when connecting your dapp to the
MetaMask mobile app.
MetaMask displays this metadata in the connection modal to help users identify and verify the
connection request.
:::
defaultReadOnlyChainId: <number or hexadecimal string>defaultReadOnlyChainId: "0x1"Enables sending read-only RPC requests to this chain ID before the user connects to MetaMask. The value is automatically updated to the chain ID used in MetaMask once connected.
enableAnalytics: <boolean>enableAnalytics: trueEnables or disables sending anonymous analytics to MetaMask to help improve the SDK.
The default is true.
extensionOnly: <boolean>extensionOnly: trueEnables or disables automatically using the MetaMask browser extension if it's detected.
The default is true.
infuraAPIKey: <string>infuraAPIKey: process.env.INFURA_API_KEYThe Infura API key to use for RPC requests. Configure this option to make read-only RPC requests from your dapp.
:::caution important Use Infura allowlists to protect against other people submitting requests to your API key. You can restrict interactions to specific addresses, origins, user agents, and request methods. We recommend using all allowlist options to maximize the security of your API key and dapp. :::
headless: <boolean>headless: trueEnables or disables headless mode.
Setting this to true allows you to display custom modals.
The default is false.
openDeeplink: <function>openDeeplink: (link: string) => {
if (canOpenLink) {
Linking.openURL(link);
}
}A function that is called to open a deeplink to the MetaMask mobile app.
readonlyRPCMap: <map>readonlyRPCMap: {
"0x539": "http://localhost:8545",
}A map of RPC URLs to use for read-only RPC requests.
shouldShimWeb3: <boolean>shouldShimWeb3: falseEnables or disables shimming the window.web3 object with the Ethereum provider returned by the SDK
(useful for compatibility with older browsers).
The default is true.