8

Trying to figure out a way to Authenticate users them having an ethereum account. New to ethereum and cryptography in general and my thought may not be adequate. In essence I am thinking to be able to authenticate users by their public ethereum account address. I have not found any straight forward solutions to this. Would it be possible and does it make sense to verify using signature of some text string? The app would ask the user to sign some text message (i assume this would have to be done in geth by user or some website), but then is there an API that can be used to verify that message? Also can this be done without spending any ether on transactions(initial gas charges)? Also how can this be done using web3?

There is a similar question here however there is no practical code solution and it may not be 100% related to my question

I have seen some posts on using metamask plugin but i do not want to have that as requirement as it seems to complicate the process and i am trying to aim towards simplifying it instead

2
  • I think MetaMask does actually simplify things, and is the most user-friendly way for anyone to interact with with Ethereum. Ultimately to prove you are the owner of an address you must be in possession of a private key, which requires a secure wallet. And I see that CryptoKitties for example relies on MetaMask for this. Jan 24, 2018 at 20:26
  • Thank You it seems metamask is currently one of the best options today Jan 24, 2018 at 22:22

1 Answer 1

4

Despite Metamask seems to complicate the process to you, if you give it a try you'll find that in reality it simplifies it for both users ( until some point ) and developpers.

To introduce a bit the topic just know that i've been on the same way as you and am developping a prototype of dApp through Angular 5, Web3js and truffle. The main idea was to have a full decentralized back-end for my prototype, which means that aside of distributing the front-end, http server wouldn't do anything else, all the back-end logic going to the ethereum network.

As i digged into Solidity i discoverd how little i knew despite reading hundreds of topics about dApp development.

I began using the Web3 object provided by Metamask in order to be able to implement my first features faster.

I had prepared a section of my Application in order to handle v3 Keystores like the one generated actually by MyEtherWallet in order to get indepedence of Metamask if user wanted to.

Whilst i achieved thanks to v1.0.0 of Web3 to decrypt the keystore file with the password i got stuck when it had to come to send signed transactions without metamask.

Below a few points about what are the complications about getting rid of Metamask :

  • You'll have to generate signature for every transaction your user will want.

  • In order to give user some control over its transaction you'll have to implement a modal or a panel that will ask user to confirm every transaction that requires gas, otherwise it will mean that your can spend user's funds as you want, imagining you store the decrypted wallet.

  • You won't be able to use Web3 for signing your transactions and will have to rely on others libraries such as ethereumjs-tx.
  • You will have to create your own accounts manager to be able to switch easily from an account to another

About last points note that using metamask in coordination with web3 you wont have to care much about those things as you'll just have to load the ABIs of your contracts and call the methods or events you want. When needing to spend gas Metamask will automatically catch the transaction request and ask confirmation. Switching accounts will take only a few seconds.

I know that this whole text doesn't provide the solution you would like but as you seem to be new, in order to be able to dig a bit without getting stuck and frustrated in complex processes and in order to dig progressively in this complexity i thought it would be a good thing to relate you how i went there and why Metamask is an affordable solution for developping first tests and prototypes.

Good luck

EDIT (on demand for code) :

You can find a starter-pack of a small dApp here The dApp shows how to detect Metamask ( which injects a Web3 Object in the window DOM Object ) and how to make small transaction.

I made a few months ago a small commented snippet on how to call method of a Contract for which we know the ABI. You'll find it here

Hope it helps !

6
  • Thanks for the help i will try the metamask from your answer it seems that node would not need to have a connection with geth, as all related functions may be carried out by metamask on the client side, which definitely simplifies development Jan 24, 2018 at 22:18
  • Something I've just learned this evening (also new to this!) is that you can also connect to Ethereum mainnet from your server via a webservice called infura.io. So users who won't have MetaMask could still perform at least the free "view" operations on your contract. Jan 24, 2018 at 23:00
  • @EmilIakoupov : You'll still need to have a node or EVM running in order to be able to make transactions. Metamask handles forging and signing the requests and sends it to the node loaded as provider. While developping the dApp i'd recommend you to run a local node like ganache-cli which will be useful for launching an EVM without have to sync. Once development is achieved you'll can deploy on a testnet to make it test to other users and ensure everything runs correctly without real cost. Once testnet ensures that you'll can deploy on mainnet.
    – Asone
    Jan 25, 2018 at 6:58
  • Last thing, if you care about quality of your code, truffle brings an extended version of mocha in order to create unit tests for your smart-contracts.
    – Asone
    Jan 25, 2018 at 7:00
  • @asone - Can you share sample code for Angular 5, Web3js and truffle
    – appbootup
    Feb 1, 2018 at 8:49

Your Answer

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

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