This page may contain legacy content

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

July 27, 2022

Sign In with Ethereum – Ethereum Auth Guide

Table of Contents

Despite the current macroeconomic climate, there’s no signal that Web3 adoption is stopping. Though, in the most immediate future, we can likely expect the internet to develop into a sort of Web2 and Web3 hybrid. However, this hybrid will require certain key aspects, such as Web3 authentication. And, since Ethereum is currently the leading blockchain network, it is vital to know how to sign in with Ethereum. So, how do you effortlessly incorporate “sign in with Ethereum” functionality into your dapps (decentralized applications)? Luckily, Moralis is the leading Web3 solution for bridging Web2 and Web3 dapps. This means you can easily sign in your users with Ethereum by merely copy-pasting a single line of code when using Moralis’ Auth API.

Moreover, you may know that Ethereum uses Ethereum Virtual Machine (EVM) to execute the code as intended. Furthermore, many other chains use EVM as a runtime environment for smart contracts. Hence, by learning to incorporate “sign in with Ethereum” functionality, you are able to deploy dapps on other EVM-compatible chains. These include BNB Chain, Polygon, and Avalanche, just to name a few. Moving forward, we will first take a closer look at why to sign in with Ethereum. Then, we will look at some of the most popular Ethereum auth solutions offered by Moralis’ Web3 Auth API. This is also where you’ll learn more about Moralis. Finally, we’ll take on an example project, where you will get to see how to create dapps that sign in with Ethereum first-hand. Moreover, we encourage you to create your own dapp. So, make sure to create your free Moralis account and follow our lead. 

Why Sign In with Ethereum?

Most current online users rely on email and password authentication. By authenticating themselves or their accounts, users get to access specific content. Moreover, this enables users to set up their personal preferences. The latter is then stored as part of users’ accounts. Furthermore, you can actually use the email-password login for Web3 applications as well. However, there must be a blockchain address somehow connected to those details. With a blockchain address (Web3 wallet), users just can’t experience the core benefits of dapps. 

Of course, it would be extremely impractical and the complete opposite of user-friendliness if users needed to provide their blockchain addresses manually. Luckily, blockchain wallets offer semi-automated Web3 authentication solutions. Via crypto wallets, users get to approve dapps to access their public address. And, when they do that on Ethereum or other EVM-compatible chains, they sign in with Ethereum. Moreover, once they do so, users get to fully engage with Web3 applications. As such, they can display their fungible token balances and NFTs (non-fungible tokens), trade their assets, utilize their assets (e.g.: Web3 games), and much more. All-in-all, in order for the users to experience the actual advantages of Web3 on EVM chains, they need to sign in with Ethereum. However, it’s your responsibility (as a dev) to make sure that the process is as user-friendly as possible. 

Moralis’ Ethereum Auth Solutions

Unless you’ve been living under a rock, you probably know Moralis as the ultimate Web3 development platform. Moralis’ main goal is to give legacy developers the tools they need for bridging Web2 and Web3. And, there are three key blockchain-related aspects of dapp development – Web3 authentication, Web3 API, and syncing on-chain events. Moreover, every dapp on Ethereum needs to have a way to sign in with Ethereum. Hence, Web3 authentication is the starting point. 

For one, Moralis’ Auth API enables you to effortlessly unify Web3 wallets and Web2 accounts in your applications. This makes it the go-to tool for devs interested in building dapps either from scratch or those just looking to add Web3 functionality to existing Web2 apps. Another great thing about Moralis’ authentication solution is its compatibility with various tech stacks. Moreover, it also gives you full control and ownership of your user data. In addition, Moralis’ Web3 Auth API supports other industry standards, such as OAuth, OpenID, DIDs, and others.  

If this is not your first rodeo with Web3 authentication implementation on Ethereum, you most likely know that it can be quite tricky. This is especially true if you don’t have the right toolset. Luckily, Moralis enables you to sign in with Ethereum without breaking a sweat. Hence, there’s no need to:

  • Redirect the users to a third-party auth interface
  • Truly understand Web3 authentication flows
  • Learn how wallets sign or verify messages
  • Master varying wallet standards
  • Discover how wallets work on different blockchains
  • Worry about the authenticating solution’s security
  • Update and maintain the auth solution

By not needing to worry and deal with all of the above, you save a lot of time and other resources. 

Save Time and Future-Proof Your Dapps

With Moralis’ Web3 authentication solution, you effortlessly sign in all your users with Ethereum. In most instances, a single line of code that you get to copy from the Moralis documentation does the trick. Hence, you cover weeks or months of work in minutes. Moreover, this is also the way to eliminate any onboarding friction. Essentially, Moralis’ unified API and comprehensive SDKs for all Web3 authentication methods enable you to focus on delivering the best UI, which is what wins the crowds.

Furthermore, Moralis is also all about cross-chain interoperability. Thus, your sign-up flows are not limited to any particular chain. After all, who knows, right? You may want to sign in with Ethereum today but things change fast in the crypto sphere. And, the last thing you want is to be stuck to any particular chain. With Moralis’ Web3 authentication solutions, you are future-proofed. You are ready for any new wallets, new chains, and new authentication methods. 

Leading Options to Sign In with Ethereum

While the blockchain industry may still be in its infancy, it already offers many amazing tools. For instance, there are countless Web3 wallets that make Web3 authentication very simple. However, Moralis decided to integrate only the most reliable options. As such, Moralis enables you to use the following solutions:

  • MetaMask – Moralis’ default “sign in with Ethereum” solution. 
  • WalletConnect – the leading solution for mobile users that supports a wide range of crypto wallets. 
  • Web3Auth – a simple non-custodial auth infrastructure that works by aggregating OAuth logins.
  • Magic – a Web authentication alternative that offers you full control over the UX.

Besides the above-mentioned auth solutions, Moralis enables you to sign in with Ethereum using any Web3 provider. Of course, in some of those cases, you’ll need to implement additional lines of code. 

What is MetaMask?

MetaMask is the most popular and most trusted cryptocurrency wallet on the market. It’s been around since 2016 and was originally designed to support the Ethereum blockchain. However, you can now add any EVM-compatible chain to MetaMask. Though, by default, it still focuses on Ethereum’s mainnet and testnets. Moreover, MetaMask can be used for more than just storing cryptocurrencies. It serves as a gateway to the Web3 sphere. It is that feature that makes MetaMask Moralis’ native option to sign in with Ethereum. In case you want to learn more about MetaMask, dive deeper into “what is MetaMask?”.

What is WalletConnect?

Unlike common belief, WalletConnect is not a crypto wallet. Instead, it is an open-source protocol for connecting dApps to mobile wallets. And, it supports a wide range of mobile wallets. Moreover, WalletConnect enables establishing the connection with QR code scanning, which is highly user-friendly. This Web3 authentication option is highly reputable and, in some aspects, a safer choice compared to desktop or browser extension wallets. We encourage you to learn more about how to authenticate users with WalletConnect.  

What is Web3Auth

If you plan on targeting users that are not familiar with Web3 tech, Web3Auth is one of the best options. It is also very secure. In fact, many popular apps, such as Skyweaver, Binance, and Ubisoft, use Web3Auth (formerly known as Torus). Essentially, Web3Auth is a simple non-custodial auth infrastructure. It works by aggregating OAuth (Google, Twitter, Discord) logins, different wallets, and existing key management solutions. Moreover, by providing a familiar login experience it can help you increase conversion rates by up to 64%. For more details, visit Web3Auth’s official website.

What is Magic?

Magic (formerly known as Fortmatic) is another reputable Web3 authentication alternative. Its uniqueness comes in the form of full control over the UX. Since Magic is customizable and embedded, it doesn’t take away users from your app. Magic is natively compatible with several blockchains. Furthermore, it includes non-custodial key management. Moreover, this Web3 auth solution also prides itself on robust security and infrastructure. In addition, Magic claims it guarantees 99.99% uptime, so you can ensure users from around the globe that they can access your apps without any hurdles. For more details, visit Magic’s official website. 

How Dapps Sign In with Ethereum – Ethereum Auth Example Project

By now you know the basics of Moralis’ authentication solution and how it can help you sign in with Ethereum. As such, it’s time to roll up our sleeves and take on an example project. And, since it is very important that your dapps cater to both desktop and mobile users, we’ll focus on an example project that does exactly that. However, before we hand you into the capable hand of our in-house expert, let’s look at our dapp demo.

Sign In with Ethereum – Dapp Demo

Let’s first look at our example dapp on a desktop device. The screenshot below clearly indicates the two buttons that users need to use to sign in with Ethereum. Basically, these buttons give users an option to choose between signing in with MetaMask or WalletConnect:

When it comes to browser users, most of them will probably go with the MetaMask authentication. As such, they will click the “Sign in using MetaMask” button, which automatically evokes MetaMask. To continue, users need to the “Sign” button: 

However, if users decide to sign in with Ethereum using WalletConnecet, they will need to click the “Sign in using WalletConnect” button. In that case, instead of prompting MetaMask, our dapp returns a pop-up modal with a QR code:

The above means that users need to use their mobile wallets to scan the code and thus complete their Web3 login. Nonetheless, once users sign in successfully, using either of the two methods, our dapps layout changes a bit. As you can see below, our dapp now shows the “Logout” button in the top-left corner and the “Wallet Logged in” message at the bottom:

Dapp Demo on Mobile

When users access our example dapp on mobile devices, they will most likely focus on signing WalletConnect. After all, the latter supports a wide range of mobile wallet applications. So, the following is a screenshot sequence that neatly demonstrates the authentication process:

The second step in the image above clearly shows a wide selection of mobile wallets that users can choose from. However, for this tutorial, we used Trust Wallet. After selecting the wallet, users just need to confirm the authentication.

Code Walkthrough

To get the most out of this article, we encourage you to try and create your own instance of the above-presented dapp. That way you will get a hang of using Moralis to implement Web3 authentication. The complete code awaits you on GitHub. Moreover, the video below, starting at 2:30 will walk you through the code.

Note: To get your own dapp credentials (dapp URL and ID), create a Moralis dapp:

Sign In with Ethereum – Ethereum Auth Guide – Summary

We covered quite a distance in today’s article. As such, you learned that certain tolls to sign in with Ethereum make a world of difference. In that aspect, Moralis and its Web3 Auth API are real game-changers. Moreover, to get you to the finish line without breaking a sweat, Moralis offers third-party integrations. Namely, MetaMask and WalletConnet. However, Moralis also supports other solutions. Here, Web3Auth and Magic are the two mention-worthy options. They both enable you to use Web2 login methods to make Web3 onboarding as smooth as possible. Last but not least, you also had a chance to take on our example project. 

If you enjoyed following our tutorial, we encourage you to visit Moralis’ Web3 blog and the Moralis’ YouTube channel. There you can find a ton of example projects and thus learn how to use Moralis to create killer dapps in minutes. Moreover, these two outlets are your ticket to continuous free crypto education. However, if you want to become blockchain certified, then Moralis Academy is the place for you. Aside from top-tier blockchain development courses, this is where you’ll get expert mentorship and a personalized study path. Nonetheless, by enrolling in Moralis Academy you also become a member of one of the most advancing communities in the crypto sphere.  

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
February 8, 2023

Ethereum Development Tools – How to Build Ethereum Projects in 2023

October 11, 2023

Check Wallet Activity and Get Crypto Address Labels

February 15, 2024

Comparing the Industry’s Leading Web3 API Providers – Moralis vs. Alchemy vs. QuickNode

January 4, 2023

Smart Contract Programming – The Ultimate 2023 Guide to Blockchain Programming

December 22, 2022

What is Danksharding? EIP-4844 and Danksharding Explained

January 4, 2024

Starknet Faucet – How to Get Testnet Funds for Starknet

December 8, 2022

How to Get NFT Collections Using Python and React

September 1, 2022

How to Create a Dapp with PlayFab and Unity in 5 Steps

November 8, 2022

How to Get All NFTs from a Contract