Git Product home page Git Product logo

vue-ethereum-ipfs's Introduction

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:

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/

vue-ethereum-ipfs's People

Contributors

10thfloor avatar donpdonp avatar fredrb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-ethereum-ipfs's Issues

js-IPFS early testers programme

We're trying to improve our release process for js-IPFS and part of that is introducing an early testers programme.

Full details are on the doc at ipfs/js-ipfs/doc/EARLY_TESTERS.md - if you'd like to join in and help out please send a PR updating that doc to add this repo and we'll open PRs here when new pre-release versions are available for testing.

Unable to npm install

Error occurs when i do npm install, showing the following message due to repository not found haadcode/ipfs-pubsub-room.git

I am following the guide step by step. I used nvm to change the verison of node i use to 8.17 (I see that when i type node -v).
I'm ubuntu and have updated my stystem.

Further, I have set up SSH with my gihub account.

This issue happens when i do npm install chalk and other packages too. This does NOT happen when i'm outside of the folder where vue-ethereum-ipfs is coppied. I can npm install chalk or other packages when i'm outside the project folder.

The error i get is:
/usr/bin/git ls-remote -h -t ssh://[email protected]/haadcode/ipfs-pubsub-room.git ERROR: Repository not found. fatal: Could not read from remote repository.

Please make sure you have the correct access rights
......

That repository does not seem to exist, and i found a repository by the same name https://github.com/ipfs-shipyard/ipfs-pubsub-room . I think replacing will fix this but i don't know how to do this.

This person seems to have the same issue but when doing something different https://stackoverflow.com/questions/66654646/npm-installation-failure-libp2p-websockets

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.