|
1 | | -# Chaincode Development Environment |
2 | | - |
3 | | -The following is a list of dependencies and recommended tools that you should install in order to develop chaincode. |
4 | | - |
5 | | -## Git |
6 | | - |
7 | | -- [Git download page](https://git-scm.com/downloads) |
8 | | -- [Pro Git ebook](https://git-scm.com/book/en/v2) |
9 | | -- [Git Desktop (for those uncomfortable with git's CLI)](https://desktop.github.com/) |
10 | | - |
11 | | -Git is a great version control tool to familiarize yourself with, both for chaincode development and software development in general. Also, git bash, which is installed with git on Windows, is an excellent alternative to the the Windows command prompt. |
12 | | - |
13 | | -### Instructions |
14 | | - |
15 | | -After following the installation instructions above, you can verify that git is installed using the following command: |
16 | | - |
17 | | -``` |
18 | | -$ git version |
19 | | -git version 2.9.0.windows.1 |
20 | | -``` |
21 | | - |
22 | | -Once you have git installed, go create an account for yourself on [GitHub](https://github.com/). The IBM Blockchain service on Bluemix currently requires that chaincode be in a GitHub repository in order to be deployed through the REST API. |
23 | | - |
24 | | -## Go |
25 | | - |
26 | | -- [Go 1.6 install](https://golang.org/dl/#go1.6.3) |
27 | | -- [Go installation instructions](https://golang.org/doc/install) |
28 | | -- [Go documentation and tutorials](https://golang.org/doc/) |
29 | | - |
30 | | -Currently, Go is the only supported language for writing chaincode. The Go installation installs a set of Go CLI tools which are very useful when writing chaincode. For example, the `go build` command allows you to check that your chaincode actually compiles before you attempt to deploy it to a network. You should install Go 1.6, so that you have the same version of the language that the fabric is written against. |
31 | | - |
32 | | -### Instructions |
33 | | - |
34 | | -Follow the installation instructions linked above. You can verify that Go is installed properly by running the following commands. Of course, the output of `go version` may change depending on your operating system. |
35 | | - |
36 | | -``` |
37 | | -$ go version |
38 | | -go version go1.6.3 windows/amd64 |
39 | | -
|
40 | | -$ echo $GOPATH |
41 | | -C:\gopath |
42 | | -``` |
43 | | - |
44 | | -Your `GOPATH` does not need to match the one above. It only matters that you have this variable set to a valid directory on your filesystem. The installation instructions linked above will take you through the setup of this environment variable. Why is this variable important? When you run `go build` to test that your chaincode compiles, Go is going to look in the `$GOPATH/src` directory for the non-standard dependencies that you list in the `import` block of your chaincode. |
45 | | - |
46 | | -## Hyperledger fabric |
47 | | - |
48 | | -- [v0.5-developer-preview Hyperledger fabric](https://github.com/hyperledger-archives/fabric/tree/v0.5-developer-preview) |
49 | | -- [v0.6-preview Hyperledger fabric](https://gerrit.hyperledger.org/r/gitweb?p=fabric.git;a=shortlog;h=refs/heads/v0.6) |
50 | | -- [master branch of the Hyperledger fabric](https://gerrit.hyperledger.org/r/gitweb?p=fabric.git;a=summary) |
51 | | - |
52 | | -Any piece of chaincode that you write will need to import the chaincode shim from Hyperledger fabric in order to be able to read and write data to/from the ledger. In order to compile chaincode locally, which you will be doing a lot, you will need to have the fabric code present in your `GOPATH`. |
53 | | - |
54 | | -### Instructions |
55 | | - |
56 | | -Three different releases of the fabric are linked above. The release you choose needs to match the Hyperledger network you are deploying your chaincode onto. You will need to make sure that the fabric release you choose is stored under `$GOPATH/src/hyperledger/fabric`. |
57 | | - |
58 | | -The instructions below should take you through the process of properly installing the v0.5 release on your `GOPATH`. |
59 | | - |
60 | | -``` |
61 | | -
|
62 | | -# Create the parent directories on your GOPATH |
63 | | -mkdir -p $GOPATH/src/github.com/hyperledger |
64 | | -cd $GOPATH/src/github.com/hyperledger |
65 | | -
|
66 | | -# Clone the appropriate release codebase into $GOPATH/src/github.com/hyperledger/fabric |
67 | | -# Note that the v0.5 release is a branch of the repository. It is defined below after the -b argument |
68 | | -git clone -b v0.5-developer-preview https://github.com/hyperledger-archives/fabric.git |
69 | | -``` |
70 | | - |
71 | | -If you are installing the v0.6 release, use this for your `git clone` command: |
72 | | - |
73 | | -``` |
74 | | -# The v0.6 release exists as a branch inside the Gerrit fabric repository |
75 | | -git clone -b v0.6 http://gerrit.hyperledger.org/r/fabric |
76 | | -``` |
77 | | - |
78 | | -If the fabric is not installed properly on your `GOPATH`, you will see errors like the one below when building your chaincode: |
79 | | -``` |
80 | | -$ go build . |
81 | | -chaincode_example02.go:27:2: cannot find package "github.com/hyperledger/fabric/core/chaincode/shim" in any of: |
82 | | - C:\Go\src\github.com\hyperledger\fabric\core\chaincode\shim (from $GOROOT) |
83 | | - C:\gopath\src\github.com\hyperledger\fabric\core\chaincode\shim (from $GOPATH) |
84 | | -``` |
85 | | - |
86 | | -A list of known specific releases is included below: |
87 | | - |
88 | | -- [Blockchain service on Bluemix](https://new-console.ng.bluemix.net/catalog/services/blockchain/) - use the v0.5-developer-preview release |
89 | | - |
90 | | -## Postman |
91 | | - |
92 | | -- [Home page](https://www.getpostman.com/) |
93 | | - |
94 | | -Postman is a REST API testing tool. Though it is deprecated, we still use the REST API in the fabric for this tutorial because it allows you to deploy and test your chaincode without needing to use the fabric SDK. You'll learn more about the fabric SDK in our other examples. |
95 | | - |
96 | | -### Instructions |
97 | | - |
98 | | -Download the [Postman tool](https://www.getpostman.com/). Depending on your operating system, you may also need to install Chrome to use Postman. Once you have the tool running, import the [request collection](../LearnChaincodeREST.postman_collection.json) included in this repository. This collection contains requests for enrolling a user on a peer, as well as deploying, invoking, and querying chaincode. The collection repository contains all the REST calls need to complete this tutorial. |
99 | | - |
100 | | -## Node.js |
101 | | - |
102 | | -- [Download links](https://nodejs.org/en/download/) |
103 | | - |
104 | | -Node.js is NOT necessary to develop chaincode, but most of our demos are built on Node.js, so it might be handy to go ahead and install it now. Also, you'll need it when you start using the fabric SDK. |
105 | | - |
106 | | -### Instructions |
107 | | - |
108 | | -Download the appropriate installation package and make sure the following commands work on your machine: |
109 | | - |
110 | | -``` |
111 | | -$ node -v |
112 | | -v4.4.7 |
113 | | -
|
114 | | -$ npm -v |
115 | | -3.10.5 |
116 | | -``` |
117 | | - |
118 | | -## IDE Suggestions |
119 | | - |
120 | | -### Visual Studio Code |
121 | | - |
122 | | -- [Download links](https://code.visualstudio.com/#alt-downloads) |
123 | | - |
124 | | -Visual Studio Code is a free IDE that supports both Node.js and Go through plugins. All of our demos and examples use either one or both of these languages. It also has tab support, git integration, and debugging support. |
125 | | - |
126 | | -### Atom |
127 | | - |
128 | | -- [Home page](https://atom.io/) |
129 | | - |
130 | | -Like VS Code, Atom has plugins to support any of the languages needed to develop chaincode or modify our examples. |
| 1 | +# Chaincode Development Environment |
| 2 | + |
| 3 | +The following is a list of dependencies and recommended tools that you should install in order to develop chaincode. |
| 4 | + |
| 5 | +## Git |
| 6 | + |
| 7 | +- [Git download page](https://git-scm.com/downloads) |
| 8 | +- [Pro Git ebook](https://git-scm.com/book/en/v2) |
| 9 | +- [Git Desktop (for those uncomfortable with git's CLI)](https://desktop.github.com/) |
| 10 | + |
| 11 | +Git is a great version control tool to familiarize yourself with, both for chaincode development and software development in general. Also, git bash, which is installed with git on Windows, is an excellent alternative to the the Windows command prompt. |
| 12 | + |
| 13 | +### Instructions |
| 14 | + |
| 15 | +After following the installation instructions above, you can verify that git is installed using the following command: |
| 16 | + |
| 17 | +``` |
| 18 | +$ git version |
| 19 | +git version 2.9.0.windows.1 |
| 20 | +``` |
| 21 | + |
| 22 | +Once you have git installed, go create an account for yourself on [GitHub](https://github.com/). The IBM Blockchain service on Bluemix currently requires that chaincode be in a GitHub repository in order to be deployed through the REST API. |
| 23 | + |
| 24 | +## Go |
| 25 | + |
| 26 | +- [Go 1.6 install](https://golang.org/dl/#go1.6.3) |
| 27 | +- [Go installation instructions](https://golang.org/doc/install) |
| 28 | +- [Go documentation and tutorials](https://golang.org/doc/) |
| 29 | + |
| 30 | +Currently, Go is the only supported language for writing chaincode. The Go installation installs a set of Go CLI tools which are very useful when writing chaincode. For example, the `go build` command allows you to check that your chaincode actually compiles before you attempt to deploy it to a network. At time of writing, this chaincode is known to build successfully with version 1.7.5. |
| 31 | + |
| 32 | +### Instructions |
| 33 | + |
| 34 | +Follow the installation instructions linked above. You can verify that Go is installed properly by running the following commands. Of course, the output of `go version` may change depending on your operating system. |
| 35 | + |
| 36 | +``` |
| 37 | +$ go version |
| 38 | +go version go1.7.5 windows/amd64 |
| 39 | +
|
| 40 | +$ echo $GOPATH |
| 41 | +C:\gopath |
| 42 | +``` |
| 43 | + |
| 44 | +Your `GOPATH` does not need to match the one above. It only matters that you have this variable set to a valid directory on your filesystem. The installation instructions linked above will take you through the setup of this environment variable. Why is this variable important? When you run `go build` to test that your chaincode compiles, Go is going to look in the `$GOPATH/src` directory for the non-standard dependencies that you list in the `import` block of your chaincode. |
| 45 | + |
| 46 | +## Hyperledger fabric |
| 47 | + |
| 48 | +- [v0.5-developer-preview Hyperledger fabric](https://github.com/hyperledger-archives/fabric/tree/v0.5-developer-preview) |
| 49 | +- [v0.6-preview Hyperledger fabric](https://gerrit.hyperledger.org/r/gitweb?p=fabric.git;a=shortlog;h=refs/heads/v0.6) |
| 50 | +- [master branch of the Hyperledger fabric](https://gerrit.hyperledger.org/r/gitweb?p=fabric.git;a=summary) |
| 51 | + |
| 52 | +Any piece of chaincode that you write will need to import the chaincode shim from Hyperledger fabric in order to be able to read and write data to/from the ledger. In order to compile chaincode locally, which you will be doing a lot, you will need to have the fabric code present in your `GOPATH`. |
| 53 | + |
| 54 | +### Instructions |
| 55 | + |
| 56 | +Three different releases of the fabric are linked above. The release you choose needs to match the Hyperledger network you are deploying your chaincode onto. You will need to make sure that the fabric release you choose is stored under `$GOPATH/src/hyperledger/fabric`. |
| 57 | + |
| 58 | +The instructions below should take you through the process of properly installing the v0.5 release on your `GOPATH`. |
| 59 | + |
| 60 | +``` |
| 61 | +
|
| 62 | +# Create the parent directories on your GOPATH |
| 63 | +mkdir -p $GOPATH/src/github.com/hyperledger |
| 64 | +cd $GOPATH/src/github.com/hyperledger |
| 65 | +
|
| 66 | +# Clone the appropriate release codebase into $GOPATH/src/github.com/hyperledger/fabric |
| 67 | +# Note that the v0.5 release is a branch of the repository. It is defined below after the -b argument |
| 68 | +git clone -b v0.5-developer-preview https://github.com/hyperledger-archives/fabric.git |
| 69 | +``` |
| 70 | + |
| 71 | +If you are installing the v0.6 release, use this for your `git clone` command: |
| 72 | + |
| 73 | +``` |
| 74 | +# The v0.6 release exists as a branch inside the Gerrit fabric repository |
| 75 | +git clone -b v0.6 http://gerrit.hyperledger.org/r/fabric |
| 76 | +``` |
| 77 | + |
| 78 | +If the fabric is not installed properly on your `GOPATH`, you will see errors like the one below when building your chaincode: |
| 79 | +``` |
| 80 | +$ go build . |
| 81 | +chaincode_example02.go:27:2: cannot find package "github.com/hyperledger/fabric/core/chaincode/shim" in any of: |
| 82 | + C:\Go\src\github.com\hyperledger\fabric\core\chaincode\shim (from $GOROOT) |
| 83 | + C:\gopath\src\github.com\hyperledger\fabric\core\chaincode\shim (from $GOPATH) |
| 84 | +``` |
| 85 | + |
| 86 | +A list of known specific releases is included below: |
| 87 | + |
| 88 | +- [Blockchain service on Bluemix](https://new-console.ng.bluemix.net/catalog/services/blockchain/) - use the v0.5-developer-preview release |
| 89 | + |
| 90 | +## Postman |
| 91 | + |
| 92 | +- [Home page](https://www.getpostman.com/) |
| 93 | + |
| 94 | +Postman is a REST API testing tool. Though it is deprecated, we still use the REST API in the fabric for this tutorial because it allows you to deploy and test your chaincode without needing to use the fabric SDK. You'll learn more about the fabric SDK in our other examples. |
| 95 | + |
| 96 | +### Instructions |
| 97 | + |
| 98 | +Download the [Postman tool](https://www.getpostman.com/). Depending on your operating system, you may also need to install Chrome to use Postman. Once you have the tool running, import the [request collection](../LearnChaincodeREST.postman_collection.json) included in this repository. This collection contains requests for enrolling a user on a peer, as well as deploying, invoking, and querying chaincode. The collection repository contains all the REST calls need to complete this tutorial. |
| 99 | + |
| 100 | +## Node.js |
| 101 | + |
| 102 | +- [Download links](https://nodejs.org/en/download/) |
| 103 | + |
| 104 | +Node.js is NOT necessary to develop chaincode, but most of our demos are built on Node.js, so it might be handy to go ahead and install it now. Also, you'll need it when you start using the fabric SDK. |
| 105 | + |
| 106 | +### Instructions |
| 107 | + |
| 108 | +Download the latest LTS installation package and make sure the following commands work on your machine: |
| 109 | + |
| 110 | +``` |
| 111 | +$ node -v |
| 112 | +v6.10.1 |
| 113 | +
|
| 114 | +$ npm -v |
| 115 | +3.10.10 |
| 116 | +``` |
| 117 | + |
| 118 | +## IDE Suggestions |
| 119 | + |
| 120 | +### Visual Studio Code |
| 121 | + |
| 122 | +- [Download links](https://code.visualstudio.com/#alt-downloads) |
| 123 | + |
| 124 | +Visual Studio Code is a free IDE that supports both Node.js and Go through plugins. All of our demos and examples use either one or both of these languages. It also has tab support, git integration, and debugging support. |
| 125 | + |
| 126 | +### Atom |
| 127 | + |
| 128 | +- [Home page](https://atom.io/) |
| 129 | + |
| 130 | +Like VS Code, Atom has plugins to support any of the languages needed to develop chaincode or modify our examples. |
0 commit comments