Skip to main content

JavaScript SDK options

The JavaScript version of MetaMask SDK takes the following options.

checkInstallationImmediately

checkInstallationImmediately: <boolean>

Enables 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

checkInstallationOnAllCalls: <boolean>

Enables or disables checking if MetaMask is installed on the user's browser before each RPC request. The default is false.

communicationServerUrl

communicationServerUrl: <string>

The URL of the communication server to use. This option is mainly used for debugging and testing the SDK.

dappMetadata

dappMetadata: {
name: <string>,
url: <string>,
iconUrl: <string>,
}

Metadata about the dapp using the SDK. The metadata options are:

  • name - Name of the dapp
  • url - URL of the dapp
  • iconUrl - URL of the dapp's icon
important

Setting dappMetaData creates a clear and trustworthy user experience when connecting your dapp to MetaMask Mobile. MetaMask Mobile displays this metadata in the connection modal to help users identify and verify the connection request.

defaultReadOnlyChainId

defaultReadOnlyChainId: <number or hexadecimal string>

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

enableAnalytics: <boolean>

Enables or disables sending anonymous analytics to MetaMask to help improve the SDK. The default is true.

extensionOnly

extensionOnly: <boolean>

Enables or disables automatically using the MetaMask browser extension if it's detected. The default is true.

infuraAPIKey

infuraAPIKey: <string>

The Infura API key to use for RPC requests. Configure this option to make read-only RPC requests from your dapp.

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

headless: <boolean>

Enables or disables headless mode. Setting this to true allows you to display custom modals. The default is false.

openDeeplink: <function>

A function that is called to open a deeplink to the MetaMask Mobile app.

readonlyRPCMap

readonlyRPCMap: <map>

A map of RPC URLs to use for read-only RPC requests.

shouldShimWeb3

shouldShimWeb3: <boolean>

Enables 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.