A getting started guilde to Fabric. Following https://hyperledger-fabric.readthedocs.io/en/latest/whatis.html to what it is.
Installation
Using Vagant and docker as a platform to try.
The detailed instructions refer to: https://github.com/zhaoxunyong/boxes/tree/main/docker/fabric
Startup
1 | Step 1: |
Starting a chaincode on the channel
1 | #https://hyperledger-fabric.readthedocs.io/en/latest/test_network.html |
Interacting with the network
1 | cd /data/fabric/fabric-samples/test-network |
Deploying a smart contract to a channel
Package the smart contract
1 | #GO |
Install the chaincode package
1 | both Org1 and org2 |
Approve a chaincode definition
1 | both Org1 and org2 |
Committing the chaincode definition to the channel
1 | "peer lifecycle chaincode commit" need to imply the both of peers of Org1 and Org2: |
Invoking the chaincode
1 | #Use the following command to create an initial set of assets on the ledger. Note the CLI does not access the Fabric Gateway peer, so each endorsing peer must be specified. |
Upgrading a smart contract
1 | #Openning a new terminal to input the following command: |
Running a Fabric Application
Set up the blockchain network
./network.sh up createChannel -c mychannel -ca
Deploy the smart contract
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-typescript/ -ccl typescript
Prepare the sample application
1 | cd ../asset-transfer-basic/application-gateway-typescript |
Running chaincode in development mode
Set up environment
1 | #git clone https://github.com/hyperledger/fabric |
Start the orderer
ORDERER_GENERAL_GENESISPROFILE=SampleDevModeSolo orderer
Start the peer in DevMode
1 | #Open another terminal window and set the required environment variables to override the peer configuration and start the peer node: |
Create channel and join peer
1 | #Open another terminal window |
Build the chaincode
1 | cd /Developer/fabric |
Start the chaincode
CORE_CHAINCODE_LOGLEVEL=debug CORE_PEER_TLS_ENABLED=false CORE_CHAINCODE_ID_NAME=mycc:1.0 ./simpleChaincode -peer.address 127.0.0.1:7052
Approve and commit the chaincode definition
1 | #Open another terminal window |
Next steps
1 | CORE_PEER_ADDRESS=127.0.0.1:7051 peer chaincode invoke -o 127.0.0.1:7050 -C ch1 -n mycc -c '{"Args":["init","a","100","b","200"]}' --isInit |