Behind the scenes: how we've integrated PatchKit Launcher with Metamask

Piotr Korzuszek

25 March 2022

We’ve recently managed to get MetaMask integrated with our Launcher. What does that mean, how did we do that, and does this change anything to Launcher users?

What is MetaMask, and why should I care?

In one sentence, MetaMask is a cryptocurrency wallet that works on the Ethereum network. If you don’t know what the Ethereum network is and know little about cryptocurrencies, you might think: why should I care? Because now, you can securely authenticate with your wallet within the Launcher.

Any authenticated user can perform actions like payments or even receive tokens to their wallets. This opens the possibility of paying for games or game items more effortless than before.

Do you see a potential in authenticating your users with MetaMask? Great, this feature is for you! If you don’t, you can just ignore it and utilize our standard authentication features like before.

The dream flow

The ideal authentication flow is where the user does not need to leave the Launcher to finish the authentication. This is sometimes difficult to achieve with auth providers like Google. MetaMask has an entirely different philosophy, and we firmly believe that it should be possible somehow.

Figures, it was easier to achieve than we initially predicted.

The research

Our Launcher runs on a Chromium-based engine, so we were looking for something that would allow us to run Chrome extensions within Electron. That’s how we’ve found electron-browser-shell project with this inside.

The prototype

Our first project to get running with our MetaMask integration was ore-forge.com and their ORE Stealth client.

We’ve got it running fairly quickly, but not without some difficulties. One of those was a popup closing bug that we had to fix. Another is a popup open event that includes a relative path to a web page that the plugin wants to open but does not hold the information about the caller. These kinds of issues are typical of new technologies, and we’re expected something like this to emerge.

Getting it into a single package

MetaMask logic and its interface work separately from the rest of the Launcher. This way, one cannot interfere with each other and makes it more secure to work with. The Launcher queries its global namespace if there’s a web3 (created by MetaMask) object available, and if there’s one, it means that the user has been authenticated and the UI can change according to that fact.

There can be a button that invokes MetaMask login flow anywhere on the UI and a button that logs out currently signed-in user. Also, the Launcher can use a JavaScript code to request a signature from the wallet’s owner. A signature is an indisputable proof that whoever signed it has full access to a wallet address which is a part of a signature.

What else?

The Launcher can utilize MetaMask API to query if your wallet contains a particular token and its amount. This can be a condition of allowing the user to download and play the game only if it is owned by the user’s wallet. This could be an excellent building block for the game marketplace and exchange service based on blockchain technology.

It’s worth mentioning that all smart contract-related operations are possible, e.g., sending or exchanging tokens, without leaving the Launcher. This opens up an excellent possibility for those who know how to utilize it.

I want to use it. What now?

Great! At the time of writing this article, the MetaMask integration is a part of our inner branch. Please tell us what you need and somebody from our team will get back to you shorly!

Subscribe to our newsletter
and stay updated.