Get Rich Quick with P2P Crypto Currency $$$$$$$$$

Get Rich Quick with P2P Crypto Currency $$$$$$$$$

Presented at Nordic.js 2017. http://nordicjs.com

Let's build something together. Expect P2P, real-time video, and audience participation! More info coming soon.

Feross Aboukhadijeh
Feross is a programmer, designer, teacher, and mad scientist based in Mountain View, CA. He's currently building WebTorrent, a streaming BitTorrent client for the browser, powered by WebRTC. Before that, he built PeerCDN, a peer-to-peer content delivery network to makes sites faster and cheaper. He's a graduate of Stanford University and he has worked at Quora, Facebook, and Intel. In the past, he did research in the Stanford human-computer interaction and computer security labs. On his free time, he works on StudyNotes, a website to help students study better.

B498d33041627b07726dc29c28f02df7?s=128

Feross Aboukhadijeh

September 07, 2017
Tweet

Transcript

  1. Get Rich Quick with P2P Crypo Currency $$$$$$$$$

  2. None
  3. None
  4. Let's make an virtual internet money ICO token crypto currency

    thingy
  5. None
  6. P2P on the Web

  7. Once upon a time...

  8. None
  9. None
  10. None
  11. Resilient

  12. No Middlemen

  13. Diverse

  14. People Powered

  15. Resilient No Middlemen Diverse People Powered

  16. P2P Peer To Peer

  17. None
  18. None
  19. Resilient?

  20. None
  21. No Middlemen?

  22. Peer 㲗 Company 㲗 Peer

  23. None
  24. Diverse?

  25. None
  26. People Powered?

  27. Client 㲗 Server

  28. None
  29. None
  30. None
  31. None
  32. None
  33. twitch.tv / ferossity

  34. P2P

  35. P2P for cost reduction » Communication Skype, Hangouts » Music

    Spotify » OS Windows Update » Game Updates Blizzard, EVE Online » Content Delivery Network PeerCDN, Peer5
  36. P2P for resilience » File sharing BitTorrent, WebTorrent » Currency

    Bitcoin » Computation Ethereum » Web Tor, I2P, Freenet » Storage IPFS, Tahoe
  37. Web ≠ P2P

  38. Domains DNS URLs

  39. Web RTC Real Time Communications

  40. WebRTC in 2017 » Approaching 100% browser support1 1 Edge

    has no Data Channel support
  41. Data Channel Hidden gem in WebRTC

  42. Client 㲗 Server

  43. Client 㲗 Client

  44. None
  45. Demos!!

  46. Download files with WebTorrent const WebTorrent = require('webtorrent') const client

    = new WebTorrent() client.add('magnet:...', function (torrent) { const file = torrent.files[0] // Display the file. Supports video, audio, images, etc. file.appendTo('body') })
  47. Let's build a community file drop site

  48. Share files with WebTorrent const WebTorrent = require('webtorrent') const dragDrop

    = require('drag-drop') const client = new WebTorrent() dragDrop('body', function (files) { client.seed(files, function (torrent) { console.log(torrent.magnetURI) }) })
  49. How do peers discover which torrents are available?

  50. Signal Hub const signalhub = require('signalhub') const hub = signalhub('demo',

    ['http://localhost:8080']) // Broadcast to a channel hub.broadcast(channel, data) // Subscribe to a channel hub.subscribe(channel).on('data', function (message) { console.log(message) })
  51. const client = new WebTorrent() dragDrop('body', function (files) { client.seed(files[0],

    function (torrent) { hub.broadcast('torrent', torrent.magnetURI) torrent.files[0].appendTo('body') }) }) hub.subscribe('torrent').on('data', function (torrentId) { client.add(torrentId, function (torrent) { torrent.files[0].appendTo('body') }) })
  52. nordicjs.fun

  53. Let's build a chat app

  54. TCP connect "connect to 127.0.0.1" ✅ connected!

  55. WebRTC handshake "i want to connect" "use this webrtc offer

    to contact me" ⏱ wait for a webrtc answer... "thanks for the webrtc answer!" ✅ connected!
  56. Simple Peer const Peer = require('simple-peer') const peer = new

    Peer() peer.on('signal', function (data) { sendToRemotePeer(data) // Send via any transport }) // Call this whern remote peer sends data function receiveFromRemotePeer (data) { peer.signal(data) }
  57. Simple Peer, Pt. 2 // Once the connection is established,

    say hello! peer.on('connect', function () { peer.send('Hello!') }) // Listen for data from remote peer peer.on('data', function (data) { console.log(data) })
  58. const randombytes = require('randombytes') const localPeerId = randombytes(8).toString('hex') hub.broadcast('hello', localPeerId)

    hub.subscribe('hello').on('data', function (peerId) { const peer = new Peer() peer.on('signal', function (signal) { hub.broadcast(peerId, signal) }) }) hub.subscribe(localPeerId, function (signal) { const peer = new Peer() peer.signal(signal) })
  59. const store = { messages: [], peers: [] } peer.on('data',

    function (message) { store.messages.push(message) update() }) function sendAll (text) { const message = { from: localPeerId, text: text } store.peers.map(function (peer) { if (peer.connected) peer.send(message) }) store.messages.push(message) update() }
  60. nordicjs.fun

  61. How performant is WebRTC data channel?

  62. Let's build a real-time game!

  63. window.addEventListener('keydown', function (event) { if (event.key === 'ArrowUp') store.keys.up =

    true else if (event.key === 'ArrowDown') store.keys.down = true else if (event.key === 'ArrowLeft') store.keys.left = true else if (event.key === 'ArrowRight') store.keys.right = true else return event.preventDefault() }) window.addEventListener('keyup', function (event) { if (event.key === 'ArrowUp') store.keys.up = false else if (event.key === 'ArrowDown') store.keys.down = false else if (event.key === 'ArrowLeft') store.keys.left = false else if (event.key === 'ArrowRight') store.keys.right = false else return event.preventDefault() })
  64. peer.on('data', function (data) { if (data.x) peer.x = data.x if

    (data.y) peer.y = data.y if (data.vx) peer.vx = data.vx if (data.vy) peer.vy = data.vy }) setInterval(function () { sendAll(store.playerPosition) // { x: 0, y: 0, vx: 0, vy: 0 } }, 100) function sendAll (position) { store.peers.map(function (peer) { if (peer.connected) peer.send(position) }) }
  65. function tick () { if (store.keys.up) store.player.vy -= K_ACCEL if

    (store.keys.down) store.player.vy += K_ACCEL if (store.keys.left) store.player.vx -= K_ACCEL if (store.keys.right) store.player.vx += K_ACCEL store.player.x += store.player.vx store.player.y += store.player.vy store.peers.forEach(function (peer) { peer.x += peer.vx peer.y += peer.vy }) update() }
  66. nordicjs.fun

  67. P2P Challenges » Topologies are complex » Trust is harder

    » Architecture is more complicated » Fewer frameworks & less starter code
  68. P2P Advantages » Cool ✨ » Reduce costs for hosting

    » Offline support automatically (often) Also: » Privacy by design (often) » User controls their data » Safe against user-hostile changes
  69. Solutions? » See work by @mafintosh, @taravancil, @pfrazee, @diasdavid, @dominic,

    @andrestaltz » Beaker Browser
  70. Thanks! @feross