Blockchain is a popular technology nowadays, where IBM Hyperledger (open source) is the leader in the alliance chain. IBM has the relevant courses.
The following is the entire process of building hyperledger fabric in your own Ubuntu development environment for reference.
First, the previous step diagram
(the original is not carefully encrypted by the DSM, can not be restored only screenshots):
2/Instructor Pre-given the installation package gave me a lot of help, mainly hyperledger-fabric-source.tar.gz this 2G has I need to install the package, save a lot of download time
Things to do before installation (all I have speculated about):
1/sodu Mkdir/data/data/install
2/Copy the hyperledger-fabric-source.tar.gz to the install directory
3/New user Fabric:sudo AddUser Fabric
Modified installation Script (note Plus execute permissions)
The modification is commented out the 11th step (dev installation of some development tools, these are not necessary)
file:///home/vincent/Hyperledger/hyperledger-fabric-setup.sh
Run the command to check if the installation was successful:
Peer version returns: Fabric Peer Server version 0.6.1-preview-snapshot-4a78b41
Peer node Status
Peer node start
(If this command adds sudo, be careful to use only FABIRC user to start, otherwise error error reading CORE_PBFT plugin config:unsupported config Type "")
Previous error: directory cannot be created/var/hyperledger/production
Because I started with the Vincent user, but I do not have permission to create the directory, so I changed it in the config file "Core.yaml" to
# Path on the file system where peer would store data
Filesystempath:/home/vincent/hyperledger
You can start it.
vincent@minipc:~$ Peer node start
17:46:51.737 [Nodecmd] Serve-INFO 001 Security enabled Status:false
17:46:51.737 [Nodecmd] Serve-INFO 002 Privacy enabled Status:false
17:46:51.737 [Eventhub_producer] Start-INFO 003 Event Processor started
17:46:51.857 [Chaincode] Newchaincodesupport-INFO 004 chaincode support using peeraddress:0.0.0.0:7051
17:46:51.858 [Sysccapi] REGISTERSYSCC-INFO 005 system Chaincode (NoOp, http://http://github.com/hyperledger/ Fabric/bddtests/syschaincode/noop) Disabled
17:46:51.858 [State] Loadconfig-INFO 006 Loading configurations ...
17:46:51.859 [State] Loadconfig, INFO 007 configurations loaded. Stateimplname=[buckettree], stateimplconfigs=map[numbuckets:%!s (int=1000003) maxgroupingateachlevel:%!s (int=5) Bucketcachesize:%!s (int=100)], deltahistorysize=[500]
17:46:51.859 [State] newstate, INFO 008 Initializing State Implementation [Buckettree]
17:46:51.859 [Buckettree] initconfig, INFO 009 configs passed during initialization = Map[string]interface {} {bucket CacheSize ": +," numbuckets ": 1000003," Maxgroupingateachlevel ": 5}
17:46:51.859 [Buckettree] initconfig-INFO 00a Initializing bucket Tree State implemetation with configurations & {maxgroupingateachlevel:5 lowestlevel:9 leveltonumbucketsmap:map[8:200001 5:1601 4:321 3:65 0:1 7:40,001 6:8,001 9:1000003 2:13 1:3] HASHFUNC:0XAB0AA0}
17:46:51.859 [Buckettree] Newbucketcache-INFO 00b constructing bucket-cache with Max bucket cache size = [+] MBs
17:46:51.859 [Buckettree] loadallbucketnodesfromdb, INFO 00c Loaded buckets data in cache. Total buckets in DB = [0]. Total Cache size:=0
17:46:51.859 [Genesis] func1, INFO 00d Creating Genesis block. --Note: creation of Genesis blocks
17:46:51.868 [Consensus/controller] newconsenter-INFO 00e Creating default consensus plugin (noops)-note: Consensus algorithms are core . YAML Configuration of
17:46:51.869 [Consensus/noops] newnoops, INFO 00f noops consensus type = *noops. Noops
17:46:51.869 [Consensus/noops] newnoops-INFO 010 noops block size = 500
17:46:51.869 [Consensus/noops] newnoops-INFO 011 noops block wait = 1s
17:46:51.870 [Nodecmd] Serve-INFO 012 starting peer with Id=name: "JDoe", network Id=dev, address=0.0.0.0:7051, Root nodes=, Validator=true
17:46:51.875 [rest] startopenchainrestserver INFO 013 Initializing the rest service on 0.0.0.0:7050, TLS is disabled .
17:46:51.875 [Consensus/statetransfer] Blockthread-INFO 014 Validated Blockchain to the Genesis block
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Start Deploying Smart contracts: (For further information, search for the keyword Hyperledger Smart contract demo resolution)
Chaincode_example02 mainly performs three core functions, Init, invoke, and query.
The init function initializes two accounts A, a, a, a, a, and a certain number of assets on a A, B account during the initial process.
The Invoke function transfers money on a and b.
The query function queries the account balances on the A and B functions.
The following is the deployment of this example, and Init, where A has released 100 pieces, and B has released 200 pieces
vincent@minipc:~$ Peer Chaincode deploy-n test_cc-p http://http://github.com/hyperledger/fabric/examples/chaincode/ Go/chaincode_example02-c ' {"Args": ["Init", "a", "+", "B", "200"]} '
Deploy Chaincode: (the deployment succeeded in returning Chaincode, which can be understood as a certain version number) Ee5b24a1f17c356dd5f6e37307922e39ddba12e5d2e203ed93401d7d05eb0dd194fb9070549c5dc31eb63f4e654dbd5a1d86cbb30c48e3ab1812590cd 0f78539
Peer Chaincode deploy-n test_cc-p Http://http://github.com/hyperledger/fabric/examples/chaincode/go/chaincode_ Example02-c ' {"Args": ["Init", "Amy", "10000", "Vincent", "20000"]} '
Deploy Chaincode: 936bc00cf66064d62e8650338db80870063ae9ae4200af0a1e06e744566d21811630c2e45a064418a77a85e0042bc8a4fbfe627299b0116555d1b26ff E44dfac
Generated a number of transactions:
21:57:42.637 [DevOps] invokeorquery-INFO 019 Transaction id:beb4626e-abe3-4b68-84d9-47d97b08d90f
21:57:53.940 [DevOps] invokeorquery-INFO 01a Transaction id:a63a77af-5135-4f51-9359-53f8adb32378
22:29:42.455 [DevOps] invokeorquery-INFO 01b Transaction ID:49CF1BBC-BAB7-463B-8FFA-D900912ECBFD
fabric@minipc:/data/sh$ Peer Chaincode query-c ' {"Function": "Query", "Args": ["a"]} '-N Ee5b24a1f17c356dd5f6e37307922e39ddba12e5d2e203ed93401d7d05eb0dd194fb9070549c5dc31eb63f4e654dbd5a1d86cbb30c48e3ab1812590cd 0f78539
Query result:100
Peer Chaincode invoke-c ' {"Function": "Query", "Args": ["Amy"]} '-N