This branch contains unity-app
- an example Unity WebGL project (2022.3+), and an altered implementation of the original next-app
.
Visit https://github.com/thirdweb-example/unity-telegram to build with v5.
Stay on this branch and follow the steps in the original readme to get setup.
Open the Unity example project, it already has thirdweb's Unity SDK imported.
-
Open
Scene_TelegramExample
-
Set the client id you previously created in your
ThirdwebManager
-
Set the
ServerUrl
andEncryptionKey
in the scene'sTelegramIAWCustomAuth
to your server url and yourNEXT_PUBLIC_AUTH_PHRASE
respectively. -
Build
-
Copy the Build folder's outputs to this repo's
root/next-app/public/unity-webgl
. (It should have Build, lib, TemplateData and index.html).
That's it, start the bot and you should see Unity load and after a few seconds, your wallet will be connected (default is Smart Wallet on Arbitrum Sepolia).
As opposed to the original project, the callback from the telegram bot starting passes the payload to unity through query params for simplicity.
From there, you simply use the Unity SDK's InAppWallet
+ AuthEndpoint
login!
Note that you must run the Unity build from Telegram for it to work properly.
var connection = new WalletConnection(
provider: WalletProvider.SmartWallet,
chainId: ThirdwebManager.Instance.SDK.Session.ChainId,
personalWallet: WalletProvider.InAppWallet,
authOptions: new AuthOptions(authProvider: AuthProvider.AuthEndpoint, jwtOrPayload: JsonConvert.SerializeObject(payload), encryptionKey: EncryptionKey)
);
var address = await ThirdwebManager.Instance.SDK.Wallet.Connect(connection);
For help or feedback, please visit our support site