Web3 applications such as DAOs and DApps are getting more and more popular. By the premises of Web3, these platforms are supposed to provide a more personal and customized experience for their users while keeping their identities private from others or even unknown to themselves.
In this project, we explore how we can enhance the user experience for such cases.
Authentication / Identity Check through Wallets
For many applications, blockchain wallets like Metamask are used to manage crypto assets such as ETH. Such wallets let users create accounts on different chains. These accounts are created with private keys; however, each account has a public address representing it.
Since public keys can be shown by anyone, but transactions related to them can only be managed by the owner, wallet connections provide a solid authentication mechanism for such applications.
The Project
In this project, we will implement a preference storage system using Next.js, where users can customize the interface provided to them. Meaning, whenever they come back to that site, they will see the UI as they intended.
Even more powerful ideas could involve normalizing user interfaces across companies' sub & cross-platforms. This way, whenever a user navigates to a certain site supporting the preferences they set on other sites, they will have a similar experience.
Also, this project can be modified to change the number of parameters for customization, allowing you to mold it into whatever structure you have in mind.
For this sample project, there are only two parameters, namely:
Copy the .env.local.example file to .env.local (which will be ignored by Git):
UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN can be found at the database details page in Upstash Console.
Dependencies
Install dependencies:
npm i @upstash/redis @metamask/detect-provider @mui/material @emotion/react @emotion/styled
Create api/store.js file
Configure Redis SDK and export the handler function.
Create api/[accountAddress].js file
Similarly, configure Redis SDK and export the handler.
Configure index.js file
Set your variables for the project
Connecting Metamask
Checking Connection when refreshed or navigated after some time
To set preferences
To get preferences
Change state of Variables
Bind the following functions to input fields/buttons etc.
Create a simple UI utilizing the above functions
Make sure you imported relevant Material-UI dependencies.
Create sampleComponent.jsx in a directory components
This is the main component representing your web interface, application, etc.
This component will visualize how the system works and the main goal it provides.
Here, parse the parameters however you like and create your sample interface.
In this instance, the project is configured as such:
Workflow
User not connected via Metamask yet. Default Template.
User connected via Metamask for the first time. Default Template.
User enters a name that they want to see when greeted to platform.
User selects between themes, namely light and dark.
User preferences are set up. From now on, same interface can be shown in any platform supporting the preference interface provided. User-customized template.
The component shows the preferences set by the user in text format; you can parse them however you like.
As you can see in this simple example, you can parametrize any component that you show to the user. You can always add to this project by improving the design and increasing the number of parameters; however, the fundamental logic stays the same.
To see the finished project, go to Github Repo of the project.
There, you will see a quick deploy button for Vercel deployment; letting you deploy the project quickly, creating an Upstash Redis integration automatically.
We are looking forward to hearing your ideas and thoughts. You can reach us via twitter or discord.