📚Mission 5
Learning to sign transactions with MetaMask
We are learning a lot of new things. In the last mission, we understood Polygon's explorer, Polygonscan, and learned to visualize our transactions in detail, understanding all the fields and what they mean.
Today we are going to introduce a new concept, that of signing transactions using MetaMask, which we set up in mission 1.
As we have already learned, a blockchain is formed by numerous blocks of transactions, and for each transaction it is necessary to use gas to complete it. We currently do not have gas in our wallet, as the MELK token has no financial value and on the Polygon network, the token used to pay gas fees is MATIC.
However, there is a type of operation that fits the concept of gas free, that is, it is not necessary to use gas to be carried out. It is called a signature.
1. What are signatures?
Signatures have been used for a long time in our society, and they serve as an authentication mechanism, proving your identity through a signature. In the web3 world, we also have this signature process, which is widely used in login systems. For this, we have a common image of the login paradigm in the different phases of the web:
![](https://docs.melkdao.xyz/~gitbook/image?url=https%3A%2F%2F2280704082-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FgJy0EoMTrVIv9RzJKxO8%252Fuploads%252FuOMzq2Oar6FPMUDo0Dwm%252Fimage%2520%2813%29%2520%283%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=5c8fb0ea&sv=1)
Signatures serve to prove that you own the wallet, that is, that you have its private key, which is often used to log into systems, as shown in the paradigm above.
With the arrival of web3, login will be much simpler, using signatures to prove your identity. In addition to being a much faster and more convenient format, it is as safe as the previous methods.
For today's mission, we are going to learn in practice how to sign a message using Metamask.
Remember: be careful where you connect your wallet for authentication. Malicious websites may use your data for harmful purposes.
2. Learning to sign a message
For this mission, we built a special website to interact with Metamask and sign a message.
To access the website, visit: https://missions.melkdao.xyz/en/basic/mission-5
Your screen should look like this:
![](https://docs.melkdao.xyz/~gitbook/image?url=https%3A%2F%2F2280704082-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FgJy0EoMTrVIv9RzJKxO8%252Fuploads%252FQeLcB79cH37BNGCxtKr4%252Fimage.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=fed5096d&sv=1)
First, read the notes for mission 5. We've specified some important details about how this mission will work and what we'll have access to.
Note that at the end of the screen we have a button, which says “Sign Message”:
![](https://docs.melkdao.xyz/~gitbook/image?url=https%3A%2F%2F2280704082-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FgJy0EoMTrVIv9RzJKxO8%252Fuploads%252F7mFemfZ31R7mLK9WEX0j%252Fbutton.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=3d3ecb79&sv=1)
Click that button. On your screen, a Metamask popup should appear. If it hasn't appeared, check if you don't have any notifications in the chrome extension.
If your metamask is not yet authorized, your screen will look like this:
![](https://docs.melkdao.xyz/~gitbook/image?url=https%3A%2F%2F2280704082-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FgJy0EoMTrVIv9RzJKxO8%252Fuploads%252FojOpKnjLgWz9tSVAHiex%252Fimage.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=36db0280&sv=1)
Let's understand what's happening here.
Metamask is asking for the password to unlock your wallet, which we don't have access to, and it's just for you to log into the wallet account.
If you are already logged into Metamask, this screen will not appear
3. Connection Consent
The second step is the consent you give to the site so that it can read your public address and with that it can identify your wallet balance.
![](https://docs.melkdao.xyz/~gitbook/image?url=https%3A%2F%2F2280704082-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FgJy0EoMTrVIv9RzJKxO8%252Fuploads%252FhDqLOGCZ6RcOtStd8z25%252Fmetamask.jpg%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=e933a53c&sv=1)
Click “Connect” to proceed.
4. Signing the Message
The next screen is the signature request and will look like this image:
![](https://docs.melkdao.xyz/~gitbook/image?url=https%3A%2F%2F2280704082-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FgJy0EoMTrVIv9RzJKxO8%252Fuploads%252FYVIWYyH5imRCgG4S3m7n%252Fimage%2520%2824%29%2520%283%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=c98f16e4&sv=1)
It is important to notice the title of the window, which says "Signature Request".
Also note that the message you are signing appears on this screen, in this case "MELK Experiment".
The button is also pretty straightforward and says "Sign". When you come across a request like this, rest assured that you are not at risk of spending money or losing the coins in your wallet.
Click “Sign”, and your screen will refresh.
![](https://docs.melkdao.xyz/~gitbook/image?url=https%3A%2F%2F2280704082-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FgJy0EoMTrVIv9RzJKxO8%252Fuploads%252FeRjIFcc5k6Zi2RKviczv%252Fimage%2520%2810%29%2520%281%29%2520%281%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=a1aca0eb&sv=1)
To copy the signature hash, click on it:
![](https://docs.melkdao.xyz/~gitbook/image?url=https%3A%2F%2F2280704082-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FgJy0EoMTrVIv9RzJKxO8%252Fuploads%252FEzlVwoTh89YJbR9YHsic%252Fimage%2520%285%29%2520%281%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=99a444c&sv=1)
Congratulations! You signed for the first time with your wallet. No information was registered on the Blockchain and so there was no need to pay fees and gas.
The site now has your accomplished signature's hash, and having knowledge of the message that was signed, it can validate that you are the holder of the private key relative to the wallet's public address.
This ensures that only you and no one else can generate this signature hash. This process proves your identity. It is a simple, effective and secure login system.
Normally, the signature hash does not appear on the screen and does not need to be manipulated by you, but in our case we show it so that you can use it as proof of the mission.
5. All ready! Now post the signature hash on Discord
Head over to the MELK Experiment Mission 5 channel on discord and post your signature hash to earn 10 MELK.
Quick reminder! This mission does not give us access to any sensitive data in your wallet, only your public address, balance and basic read permissions so that the signature hash can be generated and used to verify your identity.
Last updated