/sourcery

Supply chains on a blockchain. It's magic.

Primary LanguageJavaScript

Sourcery

Where does your food come from?

When you buy an "organic" piece of fruit, what does that really mean? If you wanted to get in touch with the people who produced it and learn more about the product, would you know how to reach them? If you found a coffee bean you couldn't get enough of, would you know how to find more when the grocery store runs out?

There are countless reasons consumers might want to trace the path backwards from table to farm. There are even more reasons why a regulator might want to use a streamlined technology to easily investigate the origins of any agricultural product, even if it's an individual fruit. This app provides an easy (and trustworthy) way to do that.

How do I use it?

This repository is the collection of smart contracts (written in Solidity for the Ethereum blockchain) that power our origin-tracking application. As a user, your internet browser will interact with our React front end which is backed by a Rails API to minimize data storage on the blockchain. You'll want to check out our production site, and if you're a developer, check out the "Getting Started" section below.

Getting Started

git clone https://github.com/ethanbennett/sourcery.git

// Install dependencies:
npm install -g truffle
npm install -g testrpc

// Run the tests:
testrpc // Let this run in a separate terminal session
truffle test

// Migrate the contracts:
truffle migrate

If this is your first time working with this language or framework, you might want to reference the Solidity or Truffle documentation. Solidity sytax highlighting is available for most text editors.

This app is deployed on the Ropsten testnet, but for the stable version, you'll need to run TestRPC locally. Here's how:

// In the sourcery directory, from the terminal, run:
testrpc // Leave this running in its own terminal
truffle migrate --reset
truffle console
// In the truffle console, run:
PathsController.deployed()
// Copy the address output and paste it over the existing address in the React project (in EthereumData.js)

This address will only work as long as your local instance of TestRPC is running. If you have to restart it, repeat the steps above.

Glossary

Here's a guide to what we mean when we say words:

  • Lot: A lot is a particular shipment of a given product. It might be a bag of coffee, a case of wine, or a pallet of diamonds. Whatever the product, a lot is its smallest unit.

  • Product: Products are names and/or descriptions, primarily used to improve the user experience. Each lot is a product: if we're talking about cases of wine, each case is a separate lot and wine is the product.

  • Path: A path is the series of steps between a customer and the lot's point of origin. If the wine originated in San Luis Obisbo, CA traveled to Salt Lake City, UT before arriving in Denver, CO the checkpoints would be those addresses in California, Utah and Colorado. In developer terms, it's an array of checkpoints. Each path is a unique contract generated by the PathsController.

  • Checkpoint: Each step in a path is a checkpoint. It represents a physical location — most likely a store or producer — and can be pinpointed on a map by referencing the location data stored in the Rails API. In the example above, a street address in each of the cities is a checkpoint.

  • Location: Locations are checkpoints, but in future releases, they'll provide a layer of security for checkpoint creation. Similar to standard authentication strategies, a location will only be able to add a checkpoint (receive or send a lot) if they actually possess the lot in the first place.

Future Features

You'll notice two branches besides master listed above: these are two pieces of functionality that are still under construction. One handles locations and permissions, the other registration. These two contracts aren't deployed to Ropsten, but they are usable to some degree with TestRPC.

About Us

We are a group of four Turing School students, and this is our capstone project for the back-end engineering program. You can learn more about our development process at these links: DTR (team expectations), stand-ups, Pivotal Tracker. And more about us at these ones: Nick, David, Ethan, Mike.