|
| 1 | +## Prerequisites and setup |
| 2 | + |
| 3 | +* [Go](https://golang.org/) - most recent version |
| 4 | +* [Docker](https://www.docker.com/products/overview) - v1.13 or higher |
| 5 | +* [Docker Compose](https://docs.docker.com/compose/overview/) - v1.8 or higher |
| 6 | +* [Node.js & npm](https://nodejs.org/en/download/) - node v6.9.5 and npm v3.10.10 |
| 7 | +* [xcode](https://developer.apple.com/xcode/) - only required for OS X users |
| 8 | +* [nvm](https://github.com/creationix/nvm/blob/master/README.markdown) - if you want to use `nvm install` command |
| 9 | +If you already have node on your machine, use the node website to install v6.9.5 or |
| 10 | +issue the following command in your terminal: |
| 11 | +```bash |
| 12 | +nvm install v6.9.5 |
| 13 | +``` |
| 14 | +then execute the following to see your versions: |
| 15 | +```bash |
| 16 | +# should be 6.9.5 |
| 17 | +node -v |
| 18 | +``` |
| 19 | +AND |
| 20 | +```bash |
| 21 | +# should be 3.10.10 |
| 22 | +npm -v |
| 23 | +``` |
| 24 | + |
| 25 | +## Curl the source code to create network entities |
| 26 | + |
| 27 | +* Download the [cURL](https://curl.haxx.se/download.html) tool if not already installed. |
| 28 | +* Determine a location on your local machine where you want to place the Fabric artifacts and application code. |
| 29 | +```bash |
| 30 | +mkdir -p <my_dev_workspace>/hackfest |
| 31 | +cd <my_dev_workspace>/hackfest |
| 32 | +``` |
| 33 | +Next, execute the following command: |
| 34 | +```bash |
| 35 | +curl -L https://raw.githubusercontent.com/hyperledger/fabric/master/examples/sfhackfest/sfhackfest.tar.gz -o sfhackfest.tar.gz 2> /dev/null; tar -xvf sfhackfest.tar.gz |
| 36 | +``` |
| 37 | +This command pulls and extracts all of the necessary artifacts to set up your |
| 38 | +network - Docker Compose script, channel generate/join script, crypto material |
| 39 | +for identity attestation, etc. In the `/src/github.com/example_cc` directory you |
| 40 | +will find the chaincode that will be deployed. |
| 41 | + |
| 42 | +Your directory should contain the following: |
| 43 | +```bash |
| 44 | +JDoe-mbp: JohnDoe$ pwd |
| 45 | +/Users/JohnDoe |
| 46 | +JDoe-mbp: JohnDoe$ ls |
| 47 | +sfhackfest.tar.gz channel_test.sh src |
| 48 | +ccenv docker-compose-gettingstarted.yml tmp |
| 49 | +``` |
| 50 | + |
| 51 | +## Using Docker |
| 52 | + |
| 53 | +You do not need to manually pull any images. The images for - `fabric-peer`, |
| 54 | +`fabric-orderer`, `fabric-ca`, and `cli` are specified in the .yml file and will |
| 55 | +automatically download, extract, and run when you execute the `docker-compose` command. |
| 56 | + |
| 57 | +## Commands |
| 58 | + |
| 59 | +The channel commands are: |
| 60 | + |
| 61 | +* `create` - create and name a channel in the `orderer` and get back a genesis |
| 62 | +block for the channel. The genesis block is named in accordance with the channel name. |
| 63 | +* `join` - use the genesis block from the `create` command to issue a join |
| 64 | +request to a peer. |
| 65 | + |
| 66 | +## Use Docker to spawn network entities & create/join a channel |
| 67 | + |
| 68 | +Ensure the hyperledger/fabric-ccenv image is tagged as latest: |
| 69 | +```bash |
| 70 | +docker-compose -f docker-compose-gettingstarted.yml build |
| 71 | +``` |
| 72 | +Create network entities, create channel, join peers to channel: |
| 73 | +```bash |
| 74 | +docker-compose -f docker-compose-gettingstarted.yml up -d |
| 75 | +``` |
| 76 | +Behind the scenes this started six containers (3 peers, a "solo" orderer, cli and CA) |
| 77 | +in detached mode. A script - `channel_test.sh` - embedded within the |
| 78 | +`docker-compose-gettingstarted.yml` issued the create channel and join channel |
| 79 | +commands within the CLI container. In the end, you are left with a network and |
| 80 | +a channel containing three peers - peer0, peer1, peer2. |
| 81 | + |
| 82 | +View your containers: |
| 83 | +```bash |
| 84 | +# if you have no other containers running, you will see six |
| 85 | +docker ps |
| 86 | +``` |
| 87 | +Ensure the channel has been created and peers have successfully joined: |
| 88 | +```bash |
| 89 | +docker exec -it cli bash |
| 90 | +``` |
| 91 | +You should see the following in your terminal: |
| 92 | +```bash |
| 93 | +/opt/gopath/src/github.com/hyperledger/fabric/peer # |
| 94 | +``` |
| 95 | +To view results for channel creation/join: |
| 96 | +```bash |
| 97 | +more results.txt |
| 98 | +``` |
| 99 | +You're looking for: |
| 100 | +```bash |
| 101 | +SUCCESSFUL CHANNEL CREATION |
| 102 | +SUCCESSFUL JOIN CHANNEL on PEER0 |
| 103 | +SUCCESSFUL JOIN CHANNEL on PEER1 |
| 104 | +SUCCESSFUL JOIN CHANNEL on PEER2 |
| 105 | +``` |
| 106 | + |
| 107 | +To view genesis block: |
| 108 | +```bash |
| 109 | +more myc1.block |
| 110 | +``` |
| 111 | + |
| 112 | +Exit the cli container: |
| 113 | +```bash |
| 114 | +exit |
| 115 | +``` |
| 116 | + |
| 117 | +## Curl the application source code and SDK modules |
| 118 | + |
| 119 | +* Prior to issuing the command, make sure you are in the same working directory |
| 120 | +where you curled the network code. AND make sure you have exited the cli container. |
| 121 | +* Execute the following command: |
| 122 | +```bash |
| 123 | +curl -OOOOOO https://raw.githubusercontent.com/hyperledger/fabric-sdk-node/v1.0-alpha/examples/balance-transfer/{config.json,deploy.js,helper.js,invoke.js,query.js,package.json} |
| 124 | +``` |
| 125 | + |
| 126 | +This command pulls the javascript code for issuing your deploy, invoke and query calls. |
| 127 | +It also retrieves dependencies for the node SDK modules. |
| 128 | + |
| 129 | +* Install the node modules: |
| 130 | +```bash |
| 131 | +# You may be prompted for your root password at one or more times during this process. |
| 132 | +npm install |
| 133 | +``` |
| 134 | +You now have all of the necessary prerequisites and Fabric artifacts. |
0 commit comments