• Stars
    star
    1,338
  • Rank 35,129 (Top 0.7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 7 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Distributed Application Starter: Vue front-end, Ethereum / IPFS Backend

vue-ethereum-ipfs

Distributed Application Starter: Vue front-end, Ethereum / IPFS Backend

Ethereum is a distributed virtual machine that pays eth in return for miners running your smart contracts. IPFS is a kind of distributed content distribution network. Vue is a javascript framework for building client-side webapps. By keeping state inside ethereum and using IPFS to deliver HTML, webapps can become nearly indestructible!

How do I use this to make indestructible Vue apps that speak Ethereum?

Before you start

Install IPFS: https://ipfs.io/docs/install/
Install the MetaMask Ethereum wallet (and register an account): https://metamask.io/
Install: npm i -g ganache-cli (local Ethereum test network)
Install: npm i -g truffle (Solidity toolkit!)

Obtain your IPFS repo key and set an environment variable

To obtain your key: ipfs key list -l
Set: export IPFS_PUBKEY=QmQozMTQHW9g6fKmHerVHoKQNQo4zhfXQMsWMTuJ6D1sJd (Example key)

Start the local Ethereum test net

Run: ganache-cli --accounts=4

Connect Metamask to the test net

Select Localhost 8545 as your RPC form the MetaMask UI

Use the generated passphrase to log into MetaMask eg:

HD Wallet
==================
Mnemonic:      shoe panic long movie sponsor clarify casino stable calm scene enforce federal

Import the other accounts in to MetaMask for testing using the generated private key eg:

Private Keys
==================
(0) 2f3a3521d79a5e5c58972224d80a678c993a1a50b7cf8a2ee51e255e55fb041d <- the passphrase unlocks this account
(1) 557d2bd6ab422edda5d57a0c20e0908c31c94a3c7c8af40c923925a3403bd214
(2) 76e98c90b7168242fd523b718a76b95966ab09904129c011582369e7339327a8
(3) 683746dee343d96dd792130b01febc0d75dd5a540fae79350db6ed9f597d

Install the Vue packages

$ npm install

Vue Build and deploy commands

 "scripts": {
    "dev":
      "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
    "start": "npm run dev",
    "unit": "jest --config test/unit/jest.conf.js --coverage",
    "e2e": "node test/e2e/runner.js",
    "test": "npm run unit && npm run e2e",
    "lint": "eslint --ext .js,.vue src test/unit test/e2e/specs",
    "build": "export IPFS_PUBKEY= && node build/build.js",
    "publish:ipfs": "npm run test && node build/build.js && node build/ipfs-publish.js"
  },
$ npm start
Your application is running here: http://localhost:8081

Create your own Smart Contracts

The easiest way to start developing Smart Contracts:

https://remix.ethereum.org/

Add contracts to the Vue App

  • Add all of your contracts (.sol files) to the /contracts directory
  • Run: truffle compile && truffle migrate --network development

Use your Contracts in the App!

Example web3Service.js. This code demonstrates a contract factory pattern. For the full code see the web3Service.js file in the project.

import contract from 'truffle-contract'

import contractJSON from '../build/contracts/WitnessContract.json'
const Contract = contract(contractJSON)

const createContractInstance = async c => {
  try {
    const newContract = await Contract.new(c.name, c.terms, {
      from: c.witness,
      gasPrice: 2000000000,
      gas: '2000000'
    })
    return newContract
  } catch (e) {
    console.log(e, 'Error creating contract...')
  }
}

export { createContractInstance }

Tested with:

  • Node (>=)9.0.0
  • go version go1.9.4 darwin/amd64
  • ipfs version 0.4.11
  • Ganache CLI v6.0.3 (ganache-core: 2.0.2)
  • Google Chrome 64.0.3282.167 (Official Build) (64-bit)

Links

Teach and learn JavaScript with us at RED Academy: https://redacademy.com/

More Repositories

1

ethereum-graphql

Node, Express, GraphQL server with a Solidity Smart Contract backend!
JavaScript
30
star
2

tonejs-starter

A starter project to get up and running making music with Tone.js.
JavaScript
25
star
3

star-wars-crawl-greensock

It's the Star Wars crawl...in a React app...animated with GreenSock!
JavaScript
15
star
4

redstarter

A WordPress starter theme for RED Academy students, forked from Underscores.
CSS
8
star
5

html-css-design-template

💻 HTML & CSS Portfolio sampler template
HTML
7
star
6

gandalf-validator

✨ Determines who shall and shall not pass form validation in React (and React Native)
JavaScript
7
star
7

blockchain-academy

Enrolment & Graduation Certificates on the Ethereum Blockchain. (Comes with Digital Currency!)
JavaScript
6
star
8

reason-react-todo

A todo app with ReasonReact + ReasonML + OCaml + BuckleScript + React
OCaml
6
star
9

codebase-review

A Node script that creates two branches (project and review) that allow you to do a PR for an entire codebase.
JavaScript
6
star
10

vue-from-mars

A WordPress theme built with Vue.js and the WP API.
CSS
5
star
11

quupe-spring-2018

Repository for the Quupe Community Project - Spring 2018
JavaScript
4
star
12

wild-spring-2018

CSS
3
star
13

best-fall-2016

CSS
3
star
14

unya-spring-2017

CSS
3
star
15

ERC20-Token-Starter

Create a basic ERC20 token using Truffle & OpenZeppelin
JavaScript
3
star
16

my7chakras-WS2-2019

PHP
3
star
17

bcParks-WS2-2019

JavaScript
3
star
18

starfish-winter-2018

CSS
2
star
19

voicestory-winter-2020

JavaScript
2
star
20

coolIt-winter-2019

JavaScript
2
star
21

beta-summer-2017

JavaScript
2
star
22

moustache-summer-2017

JavaScript
2
star
23

it-winter-2018

JavaScript
2
star
24

potlucky-winter-2017

Potlucky App Community Project - Winter 2017
JavaScript
2
star
25

funds-fall-2016

PHP
2
star
26

catalyst-winter-2017

CSS
2
star
27

boomtown-starter-v1

[ARCHIVED] A Create React App project with a few extra bells and whistles to start the ADP Boomtown project.
JavaScript
2
star
28

inhabitent-blocks

Custom Gutenberg blocks for the Inhabitent website project.
JavaScript
2
star
29

larivo-WS2-2019

JavaScript
2
star
30

edify-summer-2018

Repository for the Edify Community Project - Summer 2018
JavaScript
2
star
31

html-fundamentals

Wiki for learning the basics of HTML
JavaScript
1
star
32

icef-winter-2017

CSS
1
star
33

radio-ws1-2019

CSS
1
star
34

MinervaSummer2019

JavaScript
1
star
35

undergui-fall-2019

CSS
1
star
36

best-spring-2019

CSS
1
star
37

mht-fall-2016

CSS
1
star
38

red-functionality

A template for a WordPress functionality plugin for RED Academy students.
PHP
1
star
39

granville-spring-2017

CSS
1
star
40

spring-spring-2016

PHP
1
star
41

bix-summer-2016

CSS
1
star
42

linc-winter-2018

CSS
1
star
43

cfs-ws1-2018

CSS
1
star
44

beyond-ws1-2019

JavaScript
1
star
45

css-fundamentals

Wiki for learning the basics of CSS
JavaScript
1
star
46

bus-ws1-2018

CSS
1
star
47

web-dev-sampler

📖 A sampler of classes from RED Academy's "Web Developer Foundation" program.
CSS
1
star
48

fed-fall-2016

Changed + Fed App
JavaScript
1
star
49

yell-fall-2016

CSS
1
star
50

pong-starter

🏓 Seed project for Pong game WDP
CSS
1
star
51

vatjss-summer-2017

CSS
1
star
52

red-widget-boilerplate

A template for a WordPress widget plugin for RED Academy students.
PHP
1
star
53

hummingbird-fall-2017

CSS
1
star
54

assistlist-summer-2018

Repository for the AssistList Community Project - Summer 2018
JavaScript
1
star
55

STCSummer2019

JavaScript
1
star
56

msb-winter-2019

JavaScript
1
star