ASQ Quality 4.0 Summit on
Disruption, Innovation, & Change
Tuesday, November 13th, 2018
Dallas TX
Morgan C. Benton
morgan.benton@gmail.com @morphatic
DISCLAIMER: Blockchain may be
hazardous to your health...
THIS SOFTWARE PRESENTATION IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND FOR THE IDEAS CONTAINED HEREIN, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE WHATSOEVER. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE IMPLEMENTATION OF SOFTWARE BASED ON THE IDEAS DISCUSSED TODAY.
(paraphrased from the MIT license...)
"I don't want to create or trade cryptocurrencies, so what possible use could I have for incorporating blockchain into the software and tools that I or my company uses or the software that I'm building for clients?"
Anyone can participate.
The ledger is freely downloadable by all participants in the network
Participation is restricted. The ledger is available only to authorized participants.
Taking a
Deep Dive
into
Hyperledger
Fabric
{
"$class": "org.acme.Shipment",
"shipmentId": "6646",
"type": "BANANAS",
"status": "IN_TRANSIT",
"unitCount": 100,
"unit": "kg",
"contract": "Contract#3298"
}
{
"$class": "org.acme.Contract",
"contractId": "3298",
"grower": "Grower#0904",
"shipper": "Shipper#7456",
"importer": "Importer#1052",
"arrivalETA": "2018-09-23T23:48:57.991Z",
"unitPrice": 0.89,
"unit": "USD",
"minTemperature": 5,
"maxTemperature": 15,
"minPenaltyFactor": 0.05,
"maxPenaltyFactor": 0.25
}
{
"$class": "org.acme.Grower",
"email": "0904",
"address": {
"$class": "org.acme.Address",
"country": "CR"
},
"accountBalance": 310448.73
}
{
"$class": "org.acme.Shipper",
"email": "7456",
"address": {
"$class": "org.acme.Address",
"country": "US"
},
"accountBalance": 18540830.66
}
{
"key": "CAR1",
"value": "Audi",
"version": 0
}
{
"key": "CAR2",
"value": {
"type": "BMW",
"color": "red",
"owner": "Jane
},
"version": 0
}
package main
import (
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric/protos/peer"
)
// SimpleAsset implements a simple chaincode to manage an asset
type SimpleAsset struct {}
// Init is called during chaincode instantiation to initialize any
// data. Note that chaincode upgrade also calls this function to reset
// or to migrate data, so be careful to avoid a scenario where you
// inadvertently clobber your ledger's data!
func (t *SimpleAsset) Init(stub shim.ChaincodeStubInterface) peer.Response {
// Get the args from the transaction proposal
args := stub.GetStringArgs()
if len(args) != 2 {
return shim.Error("Incorrect arguments. Expecting a key and a value")
}
// Set up any variables or assets here by calling stub.PutState()
// We store the key and the value on the ledger
err := stub.PutState(args[0], []byte(args[1]))
if err != nil {
return shim.Error(fmt.Sprintf("Failed to create asset: %s", args[0]))
}
return shim.Success(nil)
}
// Invoke is called per transaction on the chaincode. Each transaction is
// either a 'get' or a 'set' on the asset created by Init function. The Set
// method may create a new asset by specifying a new key-value pair.
func (t *SimpleAsset) Invoke(stub shim.ChaincodeStubInterface) peer.Response {
// Extract the function and args from the transaction proposal
fn, args := stub.GetFunctionAndParameters()
var result string
var err error
if fn == "set" {
result, err = set(stub, args)
} else {
result, err = get(stub, args)
}
if err != nil {
return shim.Error(err.Error())
}
// Return the result as success payload
return shim.Success([]byte(result))
}
Example of a network with channels