All Projects → SwapyNetwork → Electron Metamask Boilerplate

SwapyNetwork / Electron Metamask Boilerplate

Easily create a desktop version of your dApp using Electron (Muon) + MetaMask.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Electron Metamask Boilerplate

The Journal Of Blockchain
区块链自媒体、专注区块链技术学习和实践、IPFS/Filecoin、Bitcoin、Ethereum、EOS、Cosmos、区块链、白皮书、Coinmarketcap、Coindesk、Safe Network、Telegram、Docker、社会治理、经济激励
Stars: ✭ 63 (-5.97%)
Mutual labels:  ethereum, dapp
Web Sdk
Portis Web SDK
Stars: ✭ 65 (-2.99%)
Mutual labels:  ethereum, dapp
Dapp
TypeScript React Redux Ethereum IPFS Starter Kit
Stars: ✭ 33 (-50.75%)
Mutual labels:  ethereum, dapp
Blockchain
블록체인 공부 중입니다.
Stars: ✭ 22 (-67.16%)
Mutual labels:  ethereum, dapp
Web3e
Web3E Ethereum for Embedded devices running Arduino framework
Stars: ✭ 50 (-25.37%)
Mutual labels:  ethereum, dapp
Augmint Web
Augmint Web Frontend
Stars: ✭ 15 (-77.61%)
Mutual labels:  ethereum, dapp
Disperse
React/Redux dApp (decentralized app) boilerplate using Ethereum's blockchain
Stars: ✭ 36 (-46.27%)
Mutual labels:  ethereum, dapp
Awesome Blockchain
区块链白皮书、书籍、交易所、币种、自媒体等资源汇总 💯
Stars: ✭ 747 (+1014.93%)
Mutual labels:  ethereum, dapp
Eth Alarm Clock Dapp
Chronos - Ethereum Alarm Clock DApp
Stars: ✭ 42 (-37.31%)
Mutual labels:  ethereum, dapp
Blockchain
区块链、交易所、币种、自媒体、高频交易策略
Stars: ✭ 37 (-44.78%)
Mutual labels:  ethereum, dapp
Eth.social
An Ethereum dApp for posting social events.
Stars: ✭ 17 (-74.63%)
Mutual labels:  ethereum, dapp
Trace
Supply chain transparency platform proof-of-concept based on the Ethereum blockchain ✍️
Stars: ✭ 52 (-22.39%)
Mutual labels:  ethereum, dapp
Blockchain Reading List
Blockchain Manchester Meetups, Talks and Reading List
Stars: ✭ 17 (-74.63%)
Mutual labels:  ethereum, dapp
Eth Hodler
A simple DApp & ERC20 token written in Solidity running on the Ethereum blockchain www.hdao.org
Stars: ✭ 31 (-53.73%)
Mutual labels:  ethereum, dapp
Web3 React
🧰 A simple, maximally extensible, dependency minimized framework for building modern Ethereum dApps
Stars: ✭ 788 (+1076.12%)
Mutual labels:  ethereum, dapp
Swarmdb
Wolk SWARMDB - Decentralized Database Services for Web3
Stars: ✭ 34 (-49.25%)
Mutual labels:  ethereum, dapp
Augur Core
Augur back-end (Ethereum contracts)
Stars: ✭ 575 (+758.21%)
Mutual labels:  ethereum, dapp
Client
(Aragon 1) Create and manage decentralized organizations on Ethereum.
Stars: ✭ 733 (+994.03%)
Mutual labels:  ethereum, dapp
Wallet
🚀 基于Flutter开发的跨终端数字货币交易所✨
Stars: ✭ 36 (-46.27%)
Mutual labels:  ethereum, dapp
Ethereumbook
Mastering Ethereum, by Andreas M. Antonopoulos, Gavin Wood
Stars: ✭ 11,663 (+17307.46%)
Mutual labels:  ethereum, dapp

Electron (Muon) + Metamask Boilerplate

Easily create a desktop version of your dApp using Electron (Muon) + MetaMask.

Introduction

When it comes to decentralized apps, the more the users don’t have to rely on third parties in order to use the application, the more trust they can put in.

Serving your frontend through cloud servers is great because anyone using a browser with MetaMask can access it, but you’re still depending on third-parties to host the code. This means that if the servers are down, *e.g.*maintenance or a DDoS attack, the users won’t be able to use the application.

On the other hand, if you created an offline version of your dApp using Electron, you wouldn't be able to use MetaMask to manage the wallets... until now.

Using this boilerplate, you'll be able to wrap your dApp code within a Muon application that includes MetaMask directly from Chrome Store!

How it works

This boilerplate is built on top of Muon, which is a security-focused fork from Electron with support for Chrome extensions. The boilerplate sets up a Muon application and injects the MetaMask extension.

  1. The npm scripts download the MetaMask code from the Chrome Store to the local folder.
  2. The Muon application renders your local HTML and injects the MetaMask content scripts.
  3. Your frontend code should use chrome.ipcRenderer.send('message') to communicate with Muon's main process and trigger the MetaMask popups.
  4. MetaMask handles all the wallet management side of the application. So you don't have to deal directly with user's private keys.
  5. Electron Builder packs and generates installers for Linux, Windows and MacOS.

How to use

Fork the repo and clone it to your local machine

git clone https://github.com/YourAccount/electron-metamask-boilerplate.git

Include your dApp frontend repository as a submodule

git submodule add https://github.com/your-awesome-company/dapp.git app

It's recommended to add the submodule with https instead of ssh. This way you can easily clone and install both the parent and the children repos (check this link).


Now the folder structure should be something like:

electron-metamask-boilerplate
  -> node_modules/

  -> extensions/

    --> metamask/

  -> main.js

  -> package.json
  
  ->  [ ... ]

  -> app - (your git repository)
    --> node_modules/

    --> src/

    --> dist/

    --> package.json

    --> [ ... ]

Setting up your project

Usually the frontend code that is rendered in the browser resides within a dist folder, so we recommend that you build your project to a dist folder so you can use our configuration without having to alter too many things.

Now, edit main.js to properly read index.html from your app's folder.

In development mode Muon will read the extensions file from the parent folder at /extensions/metamask, but when bundling to production, Electron Builder will expect the same folder at app/dist/extensions/metamask (this can be changed in extensions.js).

We've set up npm scripts to download MetaMask from Chrome Store. When in development run npm run download.metamask.dev. In production npm run download.metamask.prod.

Once you're ready run npm start for a development server.

Managing MetaMask's popups

Unfortunately, the built-in communication between the MetaMask scripts to trigger the UI doesn't work on Muon. In order to make the popups work, you'll need to intercept the web3 calls and manually send a message to Muon.

Check out this function.

Building the installers

Electron Builder depends on both package.jsons to generate the installers. For more info, check the docs.

External Resources

swapy-exchange-electron-wrapper

Swapy's article on how we did the Electron + MetaMask integration

Aragon's implementation

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].