Set up Infura in Unity
You can set up MetaMask SDK with Infura in your Unity game.
Prerequisites
-
An Infura API key. Create one by following the first two steps in the Infura getting started guide.
-
An allowlist configured for your API key.
importantYour API key, when used with the SDK, is vulnerable to exposure. If someone inspects your dapp's code, they can potentially retrieve your API key and submit requests to Infura, impersonating your account.
Use allowlists to protect against this vulnerability. You can restrict interactions with your API key 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.
-
MetaMask SDK set up in your Unity game.
Steps
-
Open your Unity project with the SDK installed.
-
Navigate to the game object in your scene (or the Prefab instance) that currently stores the
MetaMask Unity
script. In theDemo
scene, this is theMetaMaskUnitySDK
game object. -
Select the
MetaMaskUnitySDK
Prefab to view its properties in the Inspector window. -
In the MetaMask Unity (Script) section, enter your Infura API key into the Infura Project Id field.
- Save your changes. This automatically configures all RPC URLs that Infura supports.