Code Monkey home page Code Monkey logo

login-with-metamask-demo's Introduction

Login with MetaMask

Build Status David (backend) David (frontend)

This demo is published as part of the corresponding blog article: "One-Click Login with Blockchain: a MetaMask Tutorial".

❗Important note. The article was written in March 2018, and in between, MetaMask introduced a breaking change. The codebase has since then been updated to support the breaking change. As such, the snippets in the article might not be exactly the same as the updated code today. The login flow however is still exactly the same. If you want to see the original code, please visit the original branch.

Live Demo

The working app can be seen here: http://amaurymartiny.com/login-with-metamask-demo/.

The backend is hosted on Now by Zeit: https://login-with-metamask.now.sh/api/users

demo

Getting Started

I use lerna to manage a monorepo of packages here. There are 2 packages: a backend which is a REST API written in Express, and a frontend which is a React single-page application. It's really a demo, so I tried to use as few libraries as possible, and the most popular ones when possible.

The simplest way to get started is to launch the demo using Docker Compose. Alternatively you could launch docker the containers manually, or run the node services using yarn.

Launch the demo using Docker Compose:

docker-compose up -d

This will leave a the bakcend listening on localhost:8000 and the frontend on localhost:3000.

Launching the demo using Docker:

Build and launch the backend:

cd backend
docker build -t login-backend .
docker run -d -p 8000:8000 login-backend

Build and launch the frontend:

cd frontend
docker build -t login-front .
docker run -d -p 3000:3000 login-frontend

You can then access the app on localhost:3000.

Start the demo using Yarn:

From the root folder of this repo, run

yarn install # Install the dependencies
yarn start # Will launch the frontend and the backend at the same time

The backend should be running on localhost:8000, and the frontend on localhost:3000.

Alternatively, you can start the frontend and the backend separately:

# Start the backend
cd packages/backend
yarn start

# Start the frontend
cd packages/frontend
yarn start

Tests

Since this project is a demo, I haven't written any tests for it. Only code linting is performed, via prettier, which you can run using yarn lint.

Credits

If you liked this demo, I appreciate small donations. My Ethereum address is 0xa395447BF15f7525484C0378c76627D45ADE0B96.


This demo is published as part of the corresponding blog article at https://www.toptal.com/ethereum/one-click-login-flows-a-metamask-tutorial.

login-with-metamask-demo's People

Contributors

amaury1093 avatar codingthat avatar filips123 avatar motoma avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.