Déployer un réseau de chaînes de blocs d’organisation unique à l’aide d’Hyperledger Fabric 2.0 et de NodeJs

Table des matières

Déployer un réseau de chaînes de blocs d’organisation unique à l’aide d’Hyperledger Fabric 2.0 et de NodeJs

Configuration

{
"peer_name": "peer0.org1.example.com",
"channelid": "mychannel",
"use_couchdb": true,
"create_history_log": true,
"couchdb_address": "http://admin:password@localhost:5984"
}

    Démarrage de l’écouteur d’événements de canal

    # Note: This command needs to be executed from the network/code directory./offChainInit.sh
    # Following command start a local instance of CouchDB using docker
    docker run -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password --publish 5990:5984 --detach --name offchaindb couchdb
    docker start offchaindb
    # You need to install Node.js version 8.9.x to use the sample application code.
    # Following command to install the required dependencies:
    npm install
    # After we have installed the application dependencies, we can use the Node.js SDK
    # to create the identity our listener application will use to interact with the
    # network. Following command is executed to enroll the admin user
    node enrollAdmin.js
    # Following command to register and enroll an application user
    node registerUser.js
    # Then we can then use our application user to start the block event listener
    node blockEventListener.js
    Listening for block events, nextblock: 0
    Added block 0 to ProcessingMap
    Added block 1 to ProcessingMap
    Added block 2 to ProcessingMap
    Added block 3 to ProcessingMap
    Added block 4 to ProcessingMap
    Added block 5 to ProcessingMap
    Added block 6 to ProcessingMap
    ------------------------------------------------
    Block Number: 0
    ------------------------------------------------
    Block Number: 1
    ------------------------------------------------
    Block Number: 2
    ------------------------------------------------
    Block Number: 3
    Block Timestamp: 2019-08-08T19:47:56.148Z
    ChaincodeID: _lifecycle
    []
    ------------------------------------------------
    ...
    ...

    blockEventListener

    BlockProcessing

    Générer des données sur la blockchain

    {
    "nextMarbleNumber": 100,
    "numberMarblesToAdd": 20
    }
    node addMarbles.js
    node transferMarble.js marble110 james
    node deleteMarble.js marble110

    Stockage CouchDB hors chaîne: