Setting up the chaincode file

Let's now set up the chaincode file.

We will work with the folder structure cloned from GitHub. The chaincode files are located in the following folder:

$GOPATH/src/trade-finance-logistics/chaincode/src/github.com/trade_workflow_v1

You can either follow the steps and inspect the code files in the folder, or you can create a new folder and create the code files as described.

  1. First, we need to create the chaincode file

In your favorite editor, create a file, tradeWorkflow.go, and include the following package and import statements:

package mainimport (    "fmt"    "errors"    "strconv"    "strings"    "encoding/json"    "github.com/hyperledger/fabric/core/chaincode/shim"    "github.com/hyperledger/fabric/core/chaincode/lib/cid"

Get Hands-On Blockchain with Hyperledger now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.