Giter Site home page Giter Site logo

ethereum-escrow's Introduction

Trustless Two-Party Escrow Via Ethereum

A "web3" distributed webapp ("dapp") powered by React using the Ethereum Virtual Machine to facilitate two party double deposit trustless escrow agreements.

Two Party Double-Deposit Trustless Escrow

In short:

  • Alice wants to buy something from Bob. They agree the value of the purchase is $10.
  • Alice puts $20 in an escrow fund, and Bob puts $10 in that same fund.
  • Bob delivers the product to Alice and confirms delivery to the escrow fund.
  • Alice (hopefully) receives the product and confirms receipt to the escrow fund.
  • Once both parties have submitted these confirmations, the escrow fund gives $20 to Bob and $10 to Alice.

The net effect of this is that Alice has received her purchase and has paid $10 to Bob.

Code Architecture

The repository uses Consensys's Truffle framework to facilitate developing, testing, and deploying an Ethereum Smart Contract that powers the dapp.

The Ethereum Foundation's Web3 Javascript Library is used to communicate with a running Ethereum node from within a web browser. This Ethereum node provides access to the Ethereum Virtual Machine (EVM), which is used to store and alter state about all active escrow agreements. The EVM functions for us as the back-end in a traditional front-end/back-end web app architecture.

React & Redux power the front-end of the web app. Redux communicates with the EVM via the web3 library to read and alter state.

Running/Developing Locally

You'll need NodeJS, Truffle (a development framework for easily building webapps that interact with Ethereum contracts) version 3, and a running Ethereum node.

An Ethereum node is a process that manages connections to the Ethereum peer-to-peer network and runs all Transactions submitted to the blockchain to build an in-memory representation of the state of the EVM (this is used by the dapp to query the EVM's state). Ethereum nodes also facilitate broadcasting new transactions to the network and to the miners that can add those transactions to the blockchain (this is used by the dapp to make changes to the EVM's state).

Several options exist for Ethereum nodes.

  • The geth and parity projects both provide standalone Ethereum node implementations, as well as miner implementations. Both tools already know how to connect to both the public test network and the real public Ethereum peer-to-peer network.
  • The Mist browser is a Chromium app that comes with geth bundled inside it and automatically configures a connection for your browser between the javascript running in the browser and the geth node running in the Chromium app. Mist can connect to either the public test network or the real public peer-to-peer network.
  • MetaMask is a browser extension that facilitates connections between your javascript and existing ethereum nodes.
  • EthereumJS TestRPC is a very lightweight tool that creates a private, local test network for you where you are the sole miner. This is by far the best tool to use for local development and local tests. It does not include a web browser, but any regular browser will be able to connect to it via the web3 library.

Here's some setup instructions for use with EthereumJS TestRPC and MetaMask in Chrome:

Running Tests

The tests use Flow, so run truffle build to compile the tests and then run truffle test ./build/test.js

ethereum-escrow's People

Contributors

andrewl33 avatar gsgalloway avatar

Watchers

 avatar  avatar

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.