TechNewsHeaven {{source.name}}




redacademy/vue-ethereum-ipfs
2018-02-19T00:08:05.8464541Z - redacademy / Hacker News
Web 3.0 Application Starter: Vue front-end, Ethereum / IPFS BackendTested with:"engines": { "node": ">= 9.0.0", "npm": ">= 5.5.1" }go version go1.9.4 darwin/amd64ipfs version 0.4.11Ganache CLI v6.0.3 (ganache-core: 2.0.2)Google Chrome 64.0.3282.167 (Official Build) (64-bit)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" },🙌 How do I use this to make indestructable Vue apps that speak Ethereum? 🙌Before you startInstall 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!) Importing contracts is done in src/web3Service.jsExample web3Service.js// Replace this with your main contract! import contractJSON from '../build/contracts/Contract.json' import contract from 'truffle-contract' import Web3 from 'web3' if (typeof web3 !== 'undefined') { web3 = new Web3(web3.currentProvider) } else { web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')) } web3.eth.getAccounts((err, res) => { web3.eth.defaultAccount = res[0] }) const Contract = contract({ abi: contractJSON.abi, binary: contractJSON.bytecode }) Contract.setProvider(web3.currentProvider) const saveContract = async c => { // https://github.com/trufflesuite/truffle-contract/issues/70 const newContract = new web3.eth.Contract(contractJSON.abi) const createdContract = await newContract .deploy({ data: contractJSON.bytecode, arguments: [c.name, c.terms] }) .send({ from: web3.eth.defaultAccount, // Someone help me understand this. gas: 5000000, gasPrice: '20000000000000' }) createdContract .on('error', () => {}) .on('receipt', () => {}) .on('confirmation', () => {}) await getContract(createdContract.options.address) } const getContract = async address => { const contract = await Contract.at(address) // Here is your contract instance!

Your favorite news


Popular news




Recommended news