This page may contain legacy content

To get our most up-to-date content please access our documentation

January 13, 2022

Web3 Authentication – The Full Guide

Table of Contents

In this article, we’ll describe everything you need to learn about Web3 authentication. However, if you want to get your hands dirty straight away, just watch this video for a step-by-step guide to Web3 authentication with Moralis:

https://www.youtube.com/watch?v=XmezdzLb154

Everything You Need to Know About Web3 Authentication

Whether a user is interacting with a DeFi protocol or wants to dive deep into the metaverse via blockchain gaming, Web3 authentication is an absolute necessity. Without the ability to login users to the blockchain, your Web3 apps will most likely fail. However, allowing users to log in to the Web3 realm provides life-changing opportunities, especially for early adopters. Therefore, if you aspire to become a blockchain developer who wants to create highly profitable next-level dApps, you should know how to implement Web3 authentication. Initially, this might seem like a daunting challenge. However, a new paradigm shift is here, and it’s called Moralis. This ultimate Web3 development platform, known as “Firebase for crypto”, enables frontend developers to implement Web3 authentication into their dApps in minutes. In turn, they can easily login users to the blockchain. 

Moving forward, you will learn the basics of Web3, Web3 authentication, and Moralis. We will show you how to complete the initial setup and access the full power of Moralis. With the ultimate Web3 SDK at your disposal, you’ll easily cover all of your backend needs with short snippets of code. These can simply be copied from the Moralis documentation, where the best Ethereum API and other powerful tools are explained. Moreover, while Ethereum remains the leading programmable chain and acts as the default network, Moralis is, in fact, cross-chain interoperable. In turn, it offers full support for most leading EVM-compatible blockchains – such as Polygon, Binance Smart Chain (BSC), Avalanche, and others. Thus, all your work is future-proofed as you can deploy your dApps across all supported chains with ease. Furthermore, you’ll also have a chance to put Web3 authentication to action herein. So, create your free Moralis account and follow our lead!

What is Web3?

In the last couple of years, there’s been a lot of talk about Web3. At first, only crypto outlets were mentioning it, but lately, even mainstream media tends to address that ongoing revolution. However, do you know what Web 3.0 is? In order for us to discuss Web3 authentication, we need to understand the basics. In a nutshell, as far as the user experience goes, Web3 aims to be similar to Web2 (most websites do these days). However, it should (ideally) be fully decentralized and have a built-in decentralized monetary system.

In reality, we will most likely deal with some sort of hybrid between Web2 and ideal Web3 for quite some time. Though, currently, every website or application that enables you to connect to any blockchain network is considered to be a Web3 app or dApp. If you’re interested in diving deeper into the Web3 discussion, use the “Web3” link above. 

What is Web3 Authentication?

Web3 authentication may sound fancy; however, it is nothing but a login tool. Moreover, while Web2 websites use email in combination with a password, Web3 apps utilize users’ crypto addresses. However, cryptography that ensures the safety of blockchain networks and users is a lot more complex. Thus, manually logging in would require dealing with private key pairs that are public, which is not at all user-friendly. Fortunately, there are many reputable hot crypto wallets that come in the form of browser extensions and mobile apps. Also, aside from handling and storing cryptocurrencies, these wallets can be used as Web3 authentication tools. We’ll talk more about hot wallets below.  

Why Do You Need Web3 Authentication?

As explained above, Web3 websites and applications run on or at least offer users to interact with specific blockchains. Thus, there must be a safe way for users to connect to those particular crypto networks. By using Web3 authentication, users are able to connect to a selected network. Once authenticated, they have a green light to interact with other authenticated users on that network. As such, every Web3 dApp needs this kind of authentication. 

However, developers building directly on top of Ethereum RPC nodes can tell you how laborious and time-consuming it is to build such authentication from scratch. Fortunately, Moralis enables you to overcome all of the limitations of RPC nodes, including authentication. Moralis comes with full integration of the leading solutions for both web and mobile authentication. As such, you get to cover this aspect with a single line of code.

Web3 Wallets

Web3 wallets are hot cryptocurrency wallets, also known as digital wallets. They come in the form of apps and browser extensions. Further, they are an essential tool for everyone looking to explore the crypto realm. A proper Web3 wallet enables users to store all sorts of crypto assets. Moreover, with cross-chain functionality clearly being the future, most crypto wallets support multiple chains. With Web3 wallets, you get to access DeFi platforms, NFT marketplaces, blockchain or NFT games, and other crypto platforms. Plus, Web3 wallets are also a must-have tool for blockchain developers. For more details about Web3 wallets, use the link at the beginning of this section.

Web3 Authentication Alternatives

Now that you know that Web3 wallets are used for Web3 authentication, let’s take a closer look at the three most reputable options, namely, MetaMask, WalletConnect, and Web3Auth. Each of these options offers a solid user experience; MetaMask and WalletConnect in combination are a perfect experience for native crypto users, while Web3Auth caters to mainstream users. Moreover, MetaMask is arguably the best for web users, while WalletConnect is a go-to tool for mobile users.

MetaMask

MetaMask was brought to life by ConsenSys back in 2016, and it has been around the longest. Moreover, like most early movers, it has gained a lot of popularity. However, MetaMask has not been sleeping on its glory. With continuous development and countless upgrades, it became an excellent and extremely powerful tool. It is available as a browser extension for Chrome, Firefox, Brave, and Edge. Furthermore, it also supports iOS and Android devices as a mobile app.

By default, MetaMask includes the Ethereum network, including all of the most popular Ethereum testnets. However, you can easily add other EVM-compatible networks. All in all, we believe that authenticating with MetaMask is easy and practical; thus, it is our top Web3 authentication alternative. In turn, building dApps with MetaMask is a whole lot simpler. Nonetheless, make sure to also check out how to launch Web3 apps with MetaMask.  

WalletConnect

Many people think WalletConnect is an app; however, it is actually an open-source protocol for establishing connections between various wallets and dApps. It is literally what the name suggests. Therefore, calling it a hot wallet is also technically not correct. WalletConnect establishes a “symmetrically encrypted connection” via a shared key of two peers. Furthermore, this Web3 authentication alternative works with more than 75 hot crypto wallets.

To make things user-friendly, WalletConnect enables the establishment of connections either by scanning QR codes or using deep links. As such, dApps with WalletConnect integration can create safe and reliable connections with ease. To learn more details about WalletConnect, use the link at the top of this section. Also, make sure to explore how to authenticate Android apps with Moralis.

Web3Auth

Web3Auth is one of the most popular and secure alternatives to bridge the gap between Web2 and Web3 for new users. It is used by popular apps such as Skyweaver, Binance, and Ubisoft among many other dApps and wallets. Web3Auth(formerly known as Torus) is a simple non-custodial auth infrastructure that works by aggregating OAuth (Google, Twitter, Discord) logins, different wallets, and existing key management solutions. It provides a familiar login experience to every user thereby increasing conversion rates by up to 64%.

You can integrate Web3Auth into your application with a couple lines of code. With web and mobile SDKs, you can customize its look for your application and even plug in your own existing auth/user base with the infrastructure.

Fortmatic

Fortmatic, now renamed to “Magic”, is another solid Web3 authentication alternative. What may be rather unique about Fortmatic is that it offers you full control over the UX. It is customizable and embedded, which means that it doesn’t take away users from your app. According to Fortmatic’s official website, Fortmatic is a better alternative to MetaMask. As mentioned above, we have been focused on using MetaMask and WalletConnect at Moralis; therefore, we leave it up to you to explore Fortmatic further. 

Web3 Authentication and Moralis

We’ve reached a point where you know more than enough about Web3 authentication, at least theoretically. So, it’s time to roll up your sleeves and get practical. Thus, you’ll be given a chance to watch over the shoulders of one of Moralis’ experts as he builds a simple and clean Web3 login page. He will guide you through all the steps – from creating a frontend to selecting which snippets of code to use to cover the backend. However, before we hand you over to our colleague’s video, let’s take you through the initial Moralis setup, step by step. 

Initial Moralis Setup – Part 1

Whether you’ll be starting your dApps from scratch (as in the video below) or using our ultimate Web3 boilerplate, you need to create your Moralis server to gain access to the backend functionality. Therefore, make sure to complete these steps:

  1. Create Your Free Moralis Account – If you haven’t created your free Moralis account yet, do so now. Simply use the link to the left. It will take you to the signup page, where you’ll get to enter your email and create your password. To complete the process, remember to click on the confirmation link, which will be sent to your email address. However, if you already have an active Moralis account, just log in to your admin area.
  1. Create a Moralis Server – Once within your Moralis admin area, navigate to the “Servers” tab (on the left-hand side in the navigation tab). Next, click on “+ Create a new Server” in the top-right corner. Then, you’ll see a drop-down menu, where you need to select the network type that best suits your needs (see the image below). In the case of example projects and testing phases, you would normally focus on the “Testnet Server” or “Local Devchain Server” options. However, once you are ready to release your dApps to the public, you’ll need to create a “Mainnet Server”.

After selecting a network type, a pop-up window will ask you to enter your server’s details. These include your server’s name (this can be anything you want), select your region, network type, and chain(s). To complete this step, click on “Add Instance”:

Initial Moralis Setup – Part 2

Note: Please keep in mind that it can take several minutes for your server to get ready. As such, you may skip steps three and four herein for now. You’ll return to them once you have your “.js” or “.env” file ready (this is where you’ll be pasting your server’s details). 

  1. Access Server Details – As soon as your server is up and running, you can access its details. Before doing so, it also makes sense to have your “.js” or “.env” file ready. To access the server URL and app ID information, click on the “View Details” button: 


By clicking that button, all the information you need (“server URL” and “application ID”) will be displayed in a new window. As you can see from the screenshot below, you get to copy the details (one by one) by clicking on the copy icons on the right-hand side next to each detail:

  1. Initialize Moralis – Now it’s time to initialize Moralis. This will finally give you full access to the power of Moralis. As a result, you will be able to cover your backend needs. Thus, populate your coding file (“.js” or “.env”) with the application ID and server URL:
    • In case you are starting from scratch, you will normally be using a “.js” file to connect to and initialize Moralis:
  • When working with the Web3 boilerplate, you will populate your “.env” file:

Put Web3 Authentication into Action

As mentioned above, it is now time to hand you over to one of Moralis’ experts. He will start by showing you what you’ll be building. Next, he will take you through the setup process. Following, he will tell you a couple of things about Next.js. Also, at 4:47, you will begin to build the frontend, followed by the inclusion of backend functionality. Plus, he will also show you how to handle errors properly. 

Web3 Authentication – Login Users to the Blockchain – Summary

Herein, we’ve covered how Web3 acts as a gateway to the crypto realm. You know how to provide users with a way to enter the world of Web3 – by implementing an authentication tool such as MetaMask. Further, now that you know what Web3 authentication is and how easily you can cover it with Moralis, you are ready to create some awesome dApps. 

Though, if you want to build up your blockchain development confidence, knowledge, and skills for free, make sure to check out the Moralis blog and the Moralis YouTube channel. On both of these platforms, we publish fresh content daily. This includes a lot of example projects where you get to follow a Moralis experts’ lead. Some of our latest topics cover GameFi and play-to-earn (P2E), how to interact with smart contracts through a website, DAO smart contract example, ERC20 contracts, how to use a The Graph alternative to integrate mint function to JS interface, and how to index the blockchain.

Moreover, in case you are interested in professional blockchain education, make sure to enroll in Moralis Academy. By doing so, you will not only access some of the best courses in the industry but also join an incredible community. Plus, you will have a chance to get one-on-one mentorship from blockchain experts. 

Moralis Money
Stay ahead of the markets with real-time, on-chain data insights. Inform your trades with true market alpha!
Moralis Money
Related Articles
November 15, 2022

Get Wallet Balance – How to Get Wallets Native Crypto Balance

December 26, 2023

ETH Gas Tracker – Full Ethereum Gas Tracker Guide

August 31, 2022

Fastest Way to Build a Web3 App

October 17, 2023

How to Monitor All ETH Transfer Transactions

November 16, 2022

Polygon Webhooks – How to Use Webhooks on Polygon 

September 28, 2022

How to Connect MetaMask to Website with NextJS

February 5, 2024

What’s the Best Altcoin API to Set Up Altcoin Data Feeds?

December 28, 2022

Exploring Top Blockchain Storage Companies and How to Use Them

November 17, 2023

How to Add the Sepolia Network to MetaMask – Full Guide