Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Decentralizing the Web with JavaScript

Decentralizing the Web with JavaScript

Ignacio Anaya

December 04, 2018
Tweet

More Decks by Ignacio Anaya

Other Decks in Programming

Transcript

  1. ! Nacho Anaya ! @ianaya89 • JavaScript Engineer @BloqInc •

    Ambassador @Auth0 • Organizer @Vuenos_Aires Decentralizing the Web with JavaScript - @ianaya89
  2. ! Hash hash(' ! ') // d2d4e9ddd66e9ce4ee288aea24a345de hash(' " ')

    // 23622db6154ea91d793647c9bd990824 Decentralizing the Web with JavaScript - @ianaya89
  3. ! Blocks const genesisBlock = hash(null, data, metaData) const currentBlock

    = hash(genesisBlock, data, metaData) /* ... */ const newBlock = hash(prevBlock, data, metaData) Decentralizing the Web with JavaScript - @ianaya89
  4. ! Smart Contracts “A set of promises, specified in digital

    form, including protocols within which the parties perform on these promises…” !" Nick Szabo Decentralizing the Web with JavaScript - @ianaya89
  5. ! Smart Contracts “A piece of code that runs in

    the blockchain!!"” !# Everyone else Decentralizing the Web with JavaScript - @ianaya89
  6. ! Uses Cases Assets Exchange - Chain Control - Data

    Ownership - Trust funds - Network Democracy Decentralizing the Web with JavaScript - @ianaya89
  7. ! Cool Projects Aragon - IPFS - Cryptokities - Golem

    - GitCoin - Decentraland - Open Bazaar - Bank Fish Decentralizing the Web with JavaScript - @ianaya89
  8. "People want to have a web they can trust. People

    want apps that help them do what they want without spying on them." !" Tim Bernes Lee Decentralizing the Web with JavaScript - @ianaya89
  9. ! Network • Main • Test (Ropsten, Kovan, Rinkeby) •

    Private • Local Decentralizing the Web with JavaScript - @ianaya89
  10. ! ganache-cli $ npm i -g ganache-cli $ ganache-cli #

    starts a local node with HTTP provider Decentralizing the Web with JavaScript - @ianaya89
  11. ! Solidity pragma solidity ^0.4.24; contract HelloCoin { mapping (address

    => uint) public balance; function mint (address receiver, uint amount) public returns(uint) { balance[receiver] += amount; return balance[receiver]; } } Decentralizing the Web with JavaScript - @ianaya89
  12. ! Truffle $ npm i -g truffle $ truffle init

    # inits a new truffle project $ truffle compile # compile contracts and generate ABI $ truffle test # run test cases $ truffle migrate # deploy/migrate contracts to the blockchain Decentralizing the Web with JavaScript - @ianaya89
  13. ! Web3 import Web3, { providers } from 'web3' const

    provider = new providers.HttpProvider('http://localhost:8545') const web3 = new Web3(provider) Decentralizing the Web with JavaScript - @ianaya89
  14. ! Truffle Contracts import { providers } from 'web3' import

    contract from 'truffle-contract' import abi from './Contratc.json' const provider = new providers.HttpProvider('http://localhost:8545') const MyContract = contract(abi) MyContract.setProvider(provider) Decentralizing the Web with JavaScript - @ianaya89