[Advanced] Duel
This document will guide you through integrating a Sample that involves Elympics Rooms API, Competitive smart contract (Duel), where player can compete on Ethereum Testnet for Tokens, while earning Respect.
This API is subject to change in the future and is not considered code-stable.
Setup Elympics SDK
- Add Elympics SDK to your game by the Package Manager using this link: https://github.com/Elympics/Unity-SDK.git
- Create an Account, Elympics Game and matchmaking queues in Developer Console
- Choose a basic fleet
- Create two matchmaking queues:
DuelandCasualwith the Pair matchamking kind. - Contact us on Discord in order to connect the
Duelqueue to the smart contract deployment (this has to be done manually). Please provide us with the matchmaking queue identifier. - Log in to Elympics inside Unity, using your account
- Enable HTTPS/WebRTC in your Game Config

Setup the Sample Package
Download the package here. Please use the newest version.
Setup Menu Scene
- Setup
Elympics SDK - Download
com.unity.nuget.newtonsoft-jsonfrom the Package Manager - Download Dotween
- Download
TMPro Essentialsand "Examples & Extras"- Import
Fonts/Roboto-Bold.ttfandResources/Fonts & Materials/Roboto-Bold SDF.asset - In
Project Settings/TextMesh Pro/Settings/DefaultSpriteAssetchangePathtoSprites/
- Import
- Import the latest package
RoomsMenuPackage - Add the
MenuScene to build settings as the initial Scene - In
Project Settings/Player/WebGL/Resolution and Presentationchange theWebGLTemplatetoElympics - Change
AuthDataStorage.ENCRYPTION_KEYandChatController.APIKeyto the values that we'll provide you with on Discord. - Chat
- In
ChatConfigchange the constantPATH_IN_RESOURCES, to{GAME_NAME}/Chat/. Make sure that the appropriate asset is present inShared/Resources/PATH_IN_RESOURCES. - Elympics contains a config for game region (warsaw, tokyo, etc). They're used by, among others, chat config, which is responsible for channels that are geo-scoped.
- In
- Build and upload the server version of the game
- Test the game on the
casualqueue and see if it's working. - Test the
competitivemode according to the testing sections below. - When the game is working correctly, you can proceed with updating the assets and artstyle to suit your game.
- Remember to use prefabs whenever possible
- Remember that the hierarchy elements below
==v==DontDestroyOnLoad_Objects==v==should not become children of otherGameObjects

- In the final non-testing build, the
IngameDebugConsoleshould be removed - In case of any doubts with assets update, please contact us on Discord.
Gameplay Scene Requirements
- Synchronize the beginning of the game (
OnGameReadyorGameReady) and the starting state for both players, usingCustomServerHandler
It should look like this:
-
Choose
DefaultServerHandlerin theElympicsObject.
-
Replace the default script with
Custom
-
Add the object from
Assets/_RoomsPackage/Gameplay/Prefabs/InitialPlayerDataHandler.prefabto the scene.
- Handle both
competitiveandcasual, games, where game information about the players is delivered viaCustomServerHandler - Synchronizing and displaying nicknames via
InitialPlayerDataHandler - Correctly handle the joining process for the gameplay. Remember that one-time actions and their effects should be synchronized via state.
- Correctly display rewards at the end of the game – display the financial reward in the case of a competitive game.
- An example implementation is placed in
Assets/_RoomsPackage/Gameplay/Prefabs/EndGamePrizes/, which is used in theEndMatchResultscript. This implementation should be adjusted to suit the game's needs, but it should prove useful to have a reference. Remember to add the remaining objects fromAssets/_RoomsPackage/Gameplay/Prefabsto your scene -Infos. Remember to initializeTokenAddressProviderMatchDatabefore callingShowPrizeReward(); - Correctly identify the winner via calling
EndGame(ResultMatchPlayerDatas result)with the correct parameters on the server side
Testing
- Downlaod Metamask plugin to your browser (other than Firefox).
- Run the correctly setup game in your main Unity Instance as well as one clone. Press play and find the correct log:
- Unfold it to find the private key.
- Select
Add account or hardware wallet in Metamaskand import the private key generated by Unity.
An account created this way can be used both in WebGL builds and in the Unity Editor. Unity automatically logs us in (always to the same account for a given editor instance), while WebGL requires manual signing in using a Wallet.
If you already have a wallet account, you can set Unity Editor to use it (in StandaloneBrowserJsConfig Scriptable Object Inspector view).
- Select the
Sepoliatest network. - Press
Import tokensand paste the address of the test USDC Token:0xf158908549032149090D59EB86B7b38BD5D15621 - Having the token ready, copy the address (blue) and use this faucet to mine some Sepolia ETH. You'll need aroung
~0.02 SepoliaETH. This is the required currency to pay for gas. - Go to the Player's Cockpit, log in using the new account, and claim test tokens.
The obtained accounts can be used both in WebGL builds and in the Unity Editor. Unity automatically logs us in (always to the same account for a given editor instance), while WebGL requires logging in to play competitive (for currency) - without logging in, we are only guests and cannot access this feature. A guest also cannot use JoinCode (it is important that they cannot access competitive rooms).
Before the first competitive match, you must deposit Trust, which can be done via the Increase button in the top bar.
You can finally create rooms and test in production! The host (by default, the room creator, unless permissions are transferred) can change room parameters. The game will start when both players mark themselves as Ready.
After the match, players return to the room and can play a rematch or change the room. In the Unity Editor, you can test interactions with Metamask using StandaloneBrowserJsConfig ScriptableObject.

For example, increasing the Signature Delay allows for verification of transitional login stages (whether the screen dims and becomes locked, and the login button is highlighted with a loading indicator and appropriate tooltip next to it). Should Confirm Signatures, on the other hand, defines whether Metamask operations (login, increasing Trust, marking Ready, etc.) should be accepted or rejected.