LennartFr / 2019-7-11-L-L-SF

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

blueband

An introduction to the IBM Blockchain Platform 2.0!

Contacts:

Linkedin.com/in/lennartfrantzell/

Linkedin.com/in/drnugent/

blueband

Learning Objectives:

  1. How do we start?

  2. On your laptop: how to install the Visual Studio Code with the IBM Blockchain Platform plugin

  3. How to create your first Smart Contract with Visual Studio Code

  4. How to launch the brand new IBM Blockchain Platform 2.0 in the IBM Cloud

blueband

Learning Objective 1: How do we start?

It all started in October during the Global Financial Crisis in 2008 with Satoshi Nakamoto and his paper BitCoin: A Peer-to-Peer Electronic Cash System which addressed a key problem in electronic commerce:

A purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without going through a financial institution.

Digital signatures provide part of the solution, but the main benefits are lost if a trusted third party is still required to prevent double-spending.

We propose a solution to the double-spending problem using a peer-to-peer network.

Let's start with Hyperledger:

Enterprise grade permissioned distributed ledger platform that offers modularity and versatility for a broad set of industry use cases.

  1. Hyperledger Fabric’s First long term support release

  2. Raft ordering service Fault Tolerance consensus algorithm

Blockchain Use Cases

IBM Blockchain Garage Services

blueband

Learning Objective 2: On your laptop: how to install the IBM Visual Studio Code with the brand new IBP plugin

An introduction to programming Hyperledger Fabric on SlideShare

IBM Blockchain Platform on SlideShare

IBM Blockchain Solutions on SlideShare

blueband

Learning Objective 3: Developing smart contracts with Visual Studio Code extension

Complete instructions: Install IBM Blockchain Platform VS Code extension for free

Go through Tutorial One in VS Code: Local Smart Contract Development.

Follow the typical workflow from generating a new smart contract project, deploying code to the local_fabric_runtime and testing your transactions via an application gateway

my-asset-contract.ts


 * SPDX-License-Identifier: Apache-2.0
 */

import { Context, Contract, Info, Returns, Transaction } from 'fabric-contract-api';
import { MyAsset } from './my-asset';

@Info({title: 'MyAssetContract', description: 'My Smart Contract' })
export class MyAssetContract extends Contract {

    @Transaction(false)
    @Returns('boolean')
    public async myAssetExists(ctx: Context, myAssetId: string): Promise<boolean> {
        const buffer = await ctx.stub.getState(myAssetId);
        return (!!buffer && buffer.length > 0);
    }

    @Transaction()
    public async createMyAsset(ctx: Context, myAssetId: string, value: string): Promise<void> {
        const exists = await this.myAssetExists(ctx, myAssetId);
        if (exists) {
            throw new Error(`The my asset ${myAssetId} already exists`);
        }
        const myAsset = new MyAsset();
        myAsset.value = value;
        const buffer = Buffer.from(JSON.stringify(myAsset));
        await ctx.stub.putState(myAssetId, buffer);
    }

    @Transaction(false)
    @Returns('MyAsset')
    public async readMyAsset(ctx: Context, myAssetId: string): Promise<MyAsset> {
        const exists = await this.myAssetExists(ctx, myAssetId);
        if (!exists) {
            throw new Error(`The my asset ${myAssetId} does not exist`);
        }
        const buffer = await ctx.stub.getState(myAssetId);
        const myAsset = JSON.parse(buffer.toString()) as MyAsset;
        return myAsset;
    }

    @Transaction()
    public async updateMyAsset(ctx: Context, myAssetId: string, newValue: string): Promise<void> {
        const exists = await this.myAssetExists(ctx, myAssetId);
        if (!exists) {
            throw new Error(`The my asset ${myAssetId} does not exist`);
        }
        const myAsset = new MyAsset();
        myAsset.value = newValue;
        const buffer = Buffer.from(JSON.stringify(myAsset));
        await ctx.stub.putState(myAssetId, buffer);
    }

    @Transaction()
    public async deleteMyAsset(ctx: Context, myAssetId: string): Promise<void> {
        const exists = await this.myAssetExists(ctx, myAssetId);
        if (!exists) {
            throw new Error(`The my asset ${myAssetId} does not exist`);
        }
        await ctx.stub.deleteState(myAssetId);
    }

}

blueband

Learning Objective 4: How to launch the brand new IBM Blockchain Platform 2.0 in the IBM Cloud

Free IBM Cloud sign-up link: https://ibm.biz/BdzMtC

How to apply promocodes

IBM Cloud Catalog link: https://cloud.ibm.com/catalog/

1) Find IBM Blockchain Platform service in the IBM Cloud: https://cloud.ibm.com/catalog?search=blockchain.

IAM Enabled= "Identity and Access Management"

3) Welcome to the IBM Blockchain platform

4) Deploy the IBM Blockchain Service on the IKS.

5) Your Cluster has been connected

6) IBM Blockchain Platform Console installed in IBM Cloud.

blueband

# Appendix

IBM Blockchain Platform Console Video Series. Follow along this four part series to set up a business network on the IBM Blockchain Platform

Deploy a Peer on the IBM Blockchain Platform

Deploy an Ordering Service on the IBM Blockchain Platform

Create and join a channel on the IBM Blockchain Platform

Debugging NPM

  1. The application uses Node.js and can sometimes get the wrong version of Node.
  2. If npm install gets errors,
  3. do: npm rebuild, npm install
  4. And if that doesn't work, do:
  5. nvm use 8.12.0 npm install or nvm use 8.12.0 npm rebuild npm install
  6. the same if npm start gets errors 1 You can also do the same if Visual Studio Code console, Local Fabric Ops pane, do Teardown and Restart Fabric Runtime
  7. If you get an error can't find xcode, do xcode-select --install

Where do we go from here?

Creating a basic Blockchain network using the IBM Blockchain Platform V2.0

SmartContract Trading using IBM Blockchain Platform Extension for VSCode (supports Fabric 1.4

Build a blockchain insurance app

IBM Developer SF Bay Area

IBM SF Bay Area Meetups

News

Does Hyperledger Fabric perform at scale?

Forbes: Blockchain Goes To Work At Walmart, Amazon, JPMorgan, Cargill and 46 Other Enterprises

Cargill Hyperledger Grid

Target Blockchain for Supply Chain

Why new off-chain storage is required for blockchains

IBM Blockchain Twitter feeds:

Jerry Cuomo IBM Fellow and CTO, instigator of Blockchain: https://twitter.com/jerrycuomo

Christopher Ferris. IBM Fellow CTO Open Technology https://twitter.com/christo4ferris

Arnaud J Le Hors. Senior Technical Staff Member: https://twitter.com/lehors

Christian Cachin Swiss Cryptographer, Zurich. https://twitter.com/cczurich?lang=en

IBM Blockchain: https://twitter.com/ibmblockchain?lang=en

Mark Parzygnat.Program Director IBM Blockchain: https://twitter.com/meetmarkp?lang=en

Whitelisting

Whitelisting.

About