Difference between revisions of "IT-SDK-Hyperledger-Fabric-Dev"

From wiki.samerhijazi.net
Jump to navigation Jump to search
(Begriffe)
(Components)
Line 28: Line 28:
 
*------------------------------------------------------------------------------
 
*------------------------------------------------------------------------------
 
* '''Blockchain-Network''':
 
* '''Blockchain-Network''':
* '''Channel''':
+
* '''Channel''': Each channel has a completely separate '''ledger'''. This means a completely separate '''blockchain''', and completely separate '''world-states'''.
 
* '''CA''' (Certificate authorities): Issue identities by generating public and private key forming key-pair that can be used to prove an identity.
 
* '''CA''' (Certificate authorities): Issue identities by generating public and private key forming key-pair that can be used to prove an identity.
 
* '''MSP''' (Memberahip Service Provider): contains a list of permissioned identities (public keys).
 
* '''MSP''' (Memberahip Service Provider): contains a list of permissioned identities (public keys).

Revision as of 19:21, 17 December 2021

Resources Allowed for Certification

Hyperledger Fabric

Node.js / JavaScript

Begriffe

  • Actor: Is an Participants like peers, users, orderers.
  • Identity: Every actor has an identity certificate.
  • Leger: Record all state transitions, result of chaincode invocations "transactions".One Leger per Channel. Ledger consists of (World-State/Blockchain)
  • Blockchain: is the main part of the ledger. is immutable (unchangeable) und stores the full history of assets modifications.
  • World-State: is a database that represent the current values of ledger states.
  • Smart-Contract: Software-Program that defines business logic.
  • Chaincode: A Smart-Contract packaged in a Chaincode then deployed to blockchain-network.
  • Client-Application: interact with blockchain network on behalf of useres.
  • Wallet: contains a sset of user identities to connects to a channel
  • Gateway: manges the network interactions on behalf of application.
  • Transaction:

Components

  • https://hyperledger-fabric.readthedocs.io/en/release-2.2/peers/peers.html
  • ------------------------------------------------------------------------------
  • Blockchain-Network:
  • Channel: Each channel has a completely separate ledger. This means a completely separate blockchain, and completely separate world-states.
  • CA (Certificate authorities): Issue identities by generating public and private key forming key-pair that can be used to prove an identity.
  • MSP (Memberahip Service Provider): contains a list of permissioned identities (public keys).
  • Peer: Is a Nodes that host a ledger and a Smart-Contract/Chaincode. Chaincodes generate transaction and access the leger.
  • Orderer:

Chaincode Deployment

  • Package the chaincode.
  • Install the chaincode package.
  • Approval the chaincode definition.
  • Commit the chaincode defintion to a channel.

Chaincode Upgrade

  • Repackage the new chaincode.
  • Install the new chaincode package.
  • Approval the new chaincode definition.
  • Commit the new chaincode defintion to a channel.

Commands

peer lifecycle chaincode package $PACKAGE_NAME.tar.gz --path $PATH_SOURCECODE --lang $LANG --label $LABEL
peer lifecycle chaincode install $PACKAGE_NAME.tat.gz
peer lifecycle chaincode queryinstalled
peer lifecycle chaincode approveformyorg --orderer $ORDERER --channelID $CHANNEL_ID --name $CHAINCOD_NAME --version 1.0 --package-id $PACKAGE_ID --sequence 1
peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_ID --name $CHAINCOD_NAME --version 1.0 --sequence 1 --output json
peer lifecycle chaincode commit --orderer $ORDERER --channelID $CHANNEL_ID --name $CHAINCODE_NAME --version 1.0 --sequence 1 --peerAddresses $PEER_ADDRESSE
peer lifecycle chaincode querycommitted --channelID $CHANNEL_ID --name $CHAINCODE_NAME
peer chaincode invoke/query --orderer $ORDERER --channelID $CHANNEL_ID --name $CHAINCODE_NAME --ctor $MASSAGE

Functions

ctx.stub.getState(key);
ctx.stub.deleteState(key);
ctx.stub.putState(key,value);
ctx.stub.getStateByRange(keyFrom, keyTo);
---------------------------------------------------------
ctx.stub.createCompositeKey(objType, [key]);
ctx.stub.splitCompositeKey(key);
ctx.stub.getStateByPartialCompositeKey(objType, []);
---------------------------------------------------------
ctx.stub.getQueryResult(queryString);
ctx.stub.getHistoryForKey(compositeKey);
---------------------------------------------------------
ctx.clientIdentity.getMSPID();
ctx.clientIdentity.getID();
---------------------------------------------------------
ctx.stub.invokeChaincode(chaincode, args, channel);