Skip to content

thirdweb-example/telegram-mini-app

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Group 2 (1)

thirdweb Telegram Mini App Example (Unity WebGL Version!)

thirdweb SDK Discord

This branch contains unity-app - an example Unity WebGL project (2022.3+), and an altered implementation of the original next-app.

This example has been supeseded by the example below using thirdweb's Unity SDK v5

Visit https://github.com/thirdweb-example/unity-telegram to build with v5.

Set up this project for Unity

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.

  1. Open Scene_TelegramExample

  2. Set the client id you previously created in your ThirdwebManager

  3. Set the ServerUrl and EncryptionKey in the scene's TelegramIAWCustomAuth to your server url and your NEXT_PUBLIC_AUTH_PHRASE respectively.

  4. Build

  5. 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).

How it works

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);

5e7b2d6120c217a46b0b73e99c6cdeb2

Support

For help or feedback, please visit our support site

About

Thirdweb's in-app wallets in Telegram using custom authentication.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •