Skip to main content

Gaming SDK 🎮

Welcome to the documentation of the Vottun Gaming SDK! This powerful SDK enables web3 login, IPFS file uploads, and NFT operations (minting, transfers, metadata retrieval, etc.) for seamless integration into your Unity projects. Enhance your gaming experience with secure and decentralized blockchain functionalities. Let's get started!



How it works​

The SDK implements the MetaMask Unity SDK to render a QR that the player can scan with his MetaMask wallet to establish connection with the game, make sure the user’s wallet is on a certain network, and get the public address of the user’s wallet.

Once the Vottun SDK has the public address, it will automatically proceed with the Web3 Login standard and will send a message to the user’s wallet with the objective of verifying that it is a real wallet and not any type of impersonation.

When all the process is done, the user will be capable of using all the Gaming API functionalities of your game.



Steps​

1. Import SDK​

Your first step is to import the Vottun SDK as any other .unitypackage file.

Once it is imported, you will notice a new tab on the top of the screen called “Tools”, you will have to navigate to Tools -> VottunSDK -> Install.

A popup window will appear, it is the package installer window, where you will install all the dependencies needed by the MetaMask SDK and the Vottun SDK. Click “install” on both dependencies, Newtonsoft.Json and JAR Resolver, once they are installed click the "Install VottunSDK" button and the installation of the main package will begin.

danger

The following error may occur, but you can ignore it:

Assembly 'Assets/ExternalDependencyManager/Editor/1.2.175/Google.IOSResolver.dll' will not be loaded due to errors:  
Unable to resolve reference 'UnityEditor.iOS.Extensions.Xcode'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.

2. Configure Vottun SDK and MetaMask SDK​

The next step is to configure the MetaMask SDK so when the player connects his wallet the information shown in the MetaMask app will match your project.

On the tabs navigate to Window -> MetaMask -> Setup Window and the MetaMask Setup popup window will appear, go to “credentials” and change the “App Name” and “App URL” fields to the name and url of your project, next uncheck the “Deep Linking” option and click on “Apply Settings”, once you are done you can close the MetaMask Setup window.

caution

This is the basic configuration to work properly with the Vottun SDK, you can configure the MetaMask SDK as you want but may create problems on the compatibility between Vottun SDK and MetaMask SDK.

Now, on the project folders, navigate to Assets -> VottunSDK -> VottunUnity -> VottunSdkConfig -> Resources. Here you will find three scriptable objects used for configuration of the Vottun SDK.

The first scriptable object is called “Gaming Api Config”, and it's where you will write the JWT code given by Vottun when you buy the Gaming API service, to get access to the API, and the URL of the gaming API, so if the URL changes in the future it’s as easy as changing the URL here, and you will not have to update the package if you don’t want to.

  • Gaming JWT: The JWT token given by Vottun
  • Gaming Url: The URL of the Gaming Api
caution

The Gaming API URL at this moment is: https://intapi.vottun.tech/game/v1 If it changes in the future, this message will be updated with the new URL.

The second scriptable object is called “Sign Message Config”, and it’s where you will configure the message that will show on the player’s wallet when the Web3 login process occurs, the player will use this message to confirm that the connection is secure and not any kind of scam or impersonation, so the message has to be clear and explain the use of all of the player’s information.

  • Domain: The domain of your project.
  • Chain ID: The ID, in numerical format, of the blockchain network that your projects use.
  • Statement: The message that will appear in the player’s wallet to sign.
  • Uri: The URL of your project.

The third scriptable object is called “Wallet Connection Config”, and it’s where you will configure the network where the player’s wallet will have to be so it can connect to your project.

  • Force Network: If you want to force the player to stay on the configured network.
  • Network ID: The ID, in hexadecimal format, of the network where your project is.
  • Network Name: The name of the network where your project is.
  • Currency Name: The name of the currency of the network where your project is.
  • Currency Symbol: The symbol of the currency of the network where your project is.
  • Currency Decimals: The number of decimals of the currency of the network where your project is.
  • Network Rpc Urls: A string array, where each string is a URL to an RPC of the network where your project is.
  • Network Block Explorer Urls: A string array, where each string is a URL to a block explorer of the network where your project is.
  • Network Icon Urls: A string array, where each string is a URL to an icon of the network where your project is.
note

The default configuration when you install the SDK is valid for the Avalanche Fuji Testnet

info

The Network Icon URLs field is optional and you can leave it as an empty array if you want, for all the other fields, you can find the needed information on websites like https://chainlist.org


3. Scene Setup​

Now it’s time to set up the scene where the Player will connect his wallet to your project.

You will need a Canvas to display the QR, you can customize it as you want, you can use one that already exists or create a new canvas, that’s totally on to you.

Then, on the project assets, you will navigate to Assets -> VottunSDK and add the prefab called QRImage as a child of your Canvas. This is a Raw Image that will display the QR that the player needs to scan to connect his wallet. You can scale it or customize it as you want.

Once you have the QRImage where you want to, navigate again to Assets -> VottunSDK and add the prefab called VottunSDK to your scene. This prefab is an Empty Gameobject with 4 Empty Gameobjects more inside, that will handle all the logic to establish the connection between your project and the player’s wallet.

  • Wallet Connection Manager: Handle all the connection process and Web3 Login process with the player’s wallet. You can disable or enable console logs of the connection process here The function “Show QR” displays the QR if the Initialize on Start of “Meta Mask Unity” is disabled.
  • Meta Mask Unity: The main script of the MetaMask SDK, here you can select if initialize the MetaMask SDK on the Start of the scene or initialize it manually.
  • Meta Mask Unity Transport Broadcaster: Loads the QR on the listener assigned to it.
  • Wallet Event Manager: Centralize all the Events of the connection of the MetaMask SDK so you will be able to subscribe to all the events in a simpler way than with only the MetaMask SDK.
tip

The event “signValidated” of the class "WalletEventManager" has the player's wallet address on its args, which are of type "SignValidatedSuccesfully" and has the attribute "walletAddress", you must subscribe to this event in order to get the player’s wallet address.

The last step of the setup is to go to the “Meta Mask Unity Transport Broadcaster” and add the QRImage prefab in the scene to its “Listeners” array.


4. Use the API​

Now you have all the configurations needed done, and it’s time to start using all the benefits of blockchain in your project.

All the functions of the API are methods in the GamingApi class (Assets -> VottunSDK -> VottunUnity -> GamingApi). You must instantiate an object of this class in your own script where you want to use the Gaming API, then call the method of the desired endpoint, passing all the parameters that the method needs.