Skip to main content

Package Workflow

Scene Preperation

  • Place JsReceiver prefab and SmartContractService on initial Scene.
  • Place ElympicsLobby prefab on initial Scene.
  • Put Web3Wallet on ElympicsLobby game object
  • Use Web3Wallet as ElympicsEthSigner reference in ElympicsLobby
  • Provide Inspector references for the Web3Wallet component, wheras SmartContractServiceConfig Scriptable Object should be copied from the package to your project locally, to ensure proper version control tracking.
  • Provide ElympicsGameConfig reference for SmartContractServiceConfig

Configuring ElympicsLobbyClient

  • Set ElympicsLobbyClient.AuthenticateOnAwake in the inspector to None.

External Authentication

After the game launches for the first time, send a message to the PlayPad to notify that the game is ready and the loading screen can be turned off. Use this method only once per game launch: ElympicsExternalCommunicator.Instance.GameStatusCommunicator.ApplicationInitialized()

Then call and await a response from: ElympicsExternalCommunicator.Instance.ExternalAuthorizer.InitializationMessage()

This method provides us ExternalAuthData.

info

Note that you should cache this data, as this method must not be used more than once per game launch.

Wallet Startup Connection

After receiving data from ExternalAuthData, if the AuthData parameter is not null, authenticate using it.

Otherwise, check the received Capabilities. If the Capabilities include ETH or TON, await the result of Web3Wallet.ConnectWeb3(). If the address is not null or empty, authenticate using AuthType.EthAddress.

Otherwise the user rejected wallet signing or wallet capabilities were unavailable, authenticate the user as a guest using AuthType.ClientSecret.

Handling Wallet Connection Events

The game should respond to ElympicsExternalCommunicator.Instance.WalletCommunicator events distributed by the PlayPad, specifically WalletConnected and WalletDisconnected. When these events occur, the game should call ElympicsLobbyClient.Instance.SignOut() and then reconnect using ConnectToElympicsAsync() with AuthType.EthAddress if connected, or with AuthType.ClientSecret if disconnected.

warning

Events occurring during matchmaking or the gameplay should not be executed immediately, and the player cannot be changed while in gameplay. Such events should be queued and executed after returning to the lobby scene.

Wallet Midgame Connection

The SDK enables connecting a wallet midgame, allowing for seamless integration of wallet functionalities even after the game has started. To achieve this, follow these steps:

  • Begin by checking for the wallet address. This is done using the following method:

ElympicsExternalCommunicator.Instance.WalletCommunicator.Connect()

  • If the wallet address is successfully retrieved, use:

ElympicsExternalCommunicator.Instance.WalletCommunicator.ExternalShowConnectToWallet()

tip

For more information about external communication methods visit the External Communication page

Ending a Match

When a match ends, the client instance should call ElympicsExternalCommunicator.Instance.WalletCommunicator.GameFinished() with the final score value as an argument. This is primarily important for Telegram bot score display purposes and serves only as a visual indicator and not a client authority.