anshuman-singh-93 / transfer-chain-js

A simple Hyperledger Sawtooth app that handles transferring of assets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Transfer Chain JS

An example of a simple blockchain app written entirely in JavaScript with Hyperledger Sawtooth. Transfer Chain allows users to create named assets and transfer them between different owners designated by a public key.

This repo includes a Transaction Processor which will can interface with a Sawtooth validator and handle validation of transactions, and a simple browser-based client which can manage public/private key-pairs and submit transactions to the Sawtooth REST API.

Installation

This project requires both Docker and Node/NPM. After installing, download this repo and run the following commands to install dependencies for the transaction processor:

cd {project directory}/processor
npm install

And these commands to install dependencies for and build the client:

cd {project directory}/client
npm install
npm run build

Running

Sawtooth Components

Use the included docker compose file to spin up some default Sawtooth components, including a validator and a REST API. Full instructions are available in the Sawtooth Documentation, but all you really need to know is, from the project directory, run this command to start Sawtooth up:

docker-compose up

And run this command to shut them down:

docker-compose down

Once running, you should be able to access the validator at tcp://localhost:4004 and the REST API at http://localhost:8008.

Transaction Processor

In a new terminal window, start up the transaction processor:

cd {project directory}/processor
npm start

Browser Client

Start the client simply by opening client/index.html in any browser.

Usage

Create a User

Users are just public/private key-pairs stored in localStorage. Create one from the "Select User" dropdown. You can use this same dropdown to switch between multiple users in localStorage.

Create an Asset

Simple type in the name of your asset under "Create Asset" and click the create button. If you selected a user, you should see that asset appear in the list at the bottom.

Transfer an Asset

Any asset you own can be transfered to another public key using the dropdowns under "Transfer Asset". Note that the transfer must be accepted by that user before it is finalized.

Accept or Reject Transfers

Any pending transfers for the selected user will appear under "Accept Asset". These can be accepted (with an immediate change in ownership) or rejected with the corresponding buttons.

Midwest JS 2017 Slides

This project was originally developed as an example for a talk at MidwestJS 2017: Blockchain App Development with JavaScript and Hyperledger Sawtooth. The slides for this talk are available online:

http://slides.com/delventhalz/blockchain-apps

About

A simple Hyperledger Sawtooth app that handles transferring of assets

License:Apache License 2.0


Languages

Language:JavaScript 92.0%Language:HTML 8.0%