For my project, I have to set up a user login option on the site (dapp) home page. I do not wish to have conventional server-side setup to save login details. Instead, I want to use web3 based Metamask or related options. For a simple log-on to the site, I do not wish to charge any ether from the user.

But the side-effect of this implementation will be on the mining of the transaction. Becuase of no incentive associated, I understand that mining of the transaction will be delayed as miners will not be interested because of zero incentives.

Is there any viable option which can trade-off both the aforementioned cases?

I believe many fellow developers must have come across this scenario, please suggest how to circumvent it. Will appreciate if supporting code or blog links can be provided that I can follow for further details?

Please excuse me for my noob status in smart contract design.

1 Answer 1


Authenticating user via smart contract doesn't sound like a good pattern at all for the reason you mentioned. Nobody is going to pay to login to a service.

However, Metamask stores a private/public key pair for you and provides with the web3 library a set of cryptographic functions. One of them is called Elliptic Curve Cryptography

Using this method, you can implement a password-less authentication where:

  • The enduser signs a piece a data with web3 and sends it to the server with his account address
  • An authentication server can then recover the account address from signature and validate that the piece of data was signed by the user.
  • The authentication server returns a JWT if the authentication is successful.

There is very good JavaScript tutorial available here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.