Implementing Social Logins To web3.unity WebGL Builds

Implementing Social Logins To web3.unity WebGL Builds

Authored by Timothy Hao Chi Ho

How to import and use social logins with WebGL builds

Why should we use social logins?

Some developers feel that having social logins (e.g. Google, Facebook, Twitter, GitHub, Discord, etc.) would be a much better entrance system for users getting into the blockchain space. Some users tend to feel more comfortable having a wallet tied to a social account they already own. This helps to speed up onboarding and reduces friction when it comes to gaining new users. With a click of a button they can authorize an account and be on their way!

What is the Torus wallet?

The Torus Wallet powered by Web3Auth is a browser-enabled web wallet that seamlessly integrates into WebGL builds. Below, we'll walk you through the wallet, how to integrate it, as well as how to use it with the web3.unity SDK.

Why use the Torus Wallet?

Torus is simple to setup and very easy to use. It allows you to login via social networks with only 1-click of a button. Through the use of various social accounts, you're able to connect and authenticate users into your game quite easily!

An amazing dashboard full of features!

Once logged, in you'll be presented with a very clean looking dashboard where you can see your balance, activity and various things that any user needs to manage their blockchain usage.

How to integrate the Torus Wallet into web3.unity

Using this wallet in WebGL builds is very simple! All you need to do is visit the index.js file in WebGLTemplates -> Web3 -> Index.js. Uncomment the torus JavaScript import at the top and uncomment the provider options in the connect field below.

Here's an example of a connect field with proper configuration. You'll see options to add an RPC, a chainID, and a networkID. Here, we've used goerli's chain config with their default RPC as this is a great place to start for any developer wanting to try transactions on a free testnet. If you need goerli eth you can obtain it from the faucet for free from the Goerli PoW Faucet.

Build your project and test it out

Once the config is set, you can press Ctrl+B from Unity to create a local build and test things out. Upon using the WebGL login scene, you'll be greeted with a pop-up allowing you to select the Torus Wallet as a form of authentication. You can see an example of this on our amazing Chicken Demo.

Making a transaction

This is extremely easy as the Torus Wallet integrates perfectly with our SDK. You can test a transaction out by walking to any of the functions and giving them a click. You'll see a little pop up asking you to authorize the transaction like so. Just press accept and watch the magic happen! You can learn more about the Chicken Demo in our blog post Demoing web3.unity With The "Chicken Demo".

That's all there is to it!

Yes! it's really that easy! We hope you enjoy having such an amazing wallet at your finger tips. We hope you develop something great and we're proud to be integrated with these amazing teams. Keep learning and happy coding!

Welcome to the new era of #web3 gaming

web3.unity is an open-source gaming SDK developed by ChainSafe Gaming that connects games built with Unity to the blockchain. The library currently supports games built for web browsers (WebGL), iOS/Android mobile, and desktop. web3.unity is compatible with most EVM-based chains such as Ethereum, Polygon, Moonbeam, Cronos, Nervos, SKALE, and Binance Smart Chain, letting developers easily choose and switch between them to create the best in-game experience.

Dive into the code via Github and check out the docs.

Share your work on social media and tag us on Twitter @ChainSafeGaming, @ChainSafeth or on LinkedIn @ ChainSafe Systems with the hashtags #web3unity or #ChainSafeGaming. We love giving shoutouts 👊

About ChainSafe

ChainSafe is a leading blockchain research and development firm specializing in infrastructure solutions for web3. Alongside its contributions to major ecosystems such as Ethereum, Polkadot, Filecoin, and more, ChainSafe creates solutions for developers and teams across the web3 space utilizing our expertise in gaming, bridging, NFTs, and decentralized storage. As part of its mission to build innovative products for users and improved tooling for developers, ChainSafe embodies an open source and community-oriented ethos to advance the future of the internet. To learn more, click here.

Website | Twitter | Linkedin | GitHub | Discord | YouTube | Newsletter