Building in Binary format
What is Binary Format?
A binary format refers to the compiled and packaged version of the chaincode that is ready for deployment onto the Fabric network. When developing chaincode, it is typically written in a high-level programming language such as Go, JavaScript, or Java. However, before it can be deployed onto the Fabric network, it needs to be compiled into a binary format.
The binary format ensures that the chaincode is in a format that can be executed by the peer nodes in the Fabric network. It typically includes all the necessary dependencies, libraries, and resources required for the chaincode to function correctly. Once the chaincode is compiled into a binary format, it can be uploaded and installed on the peer nodes, allowing it to be invoked and executed as part of the blockchain network's transactions.
Compiling / Building Go Binary or JAVA jar files notes:
The OS and the Architecture matter when compiling Golang code. For instance, for an executable to work with Ubuntu OS with amd64 architecture, the binary also needs to be built under similar environments.
It is highly recommended to build the chaincode inside docker containers with the hyper ledger fabric runtime environment images to avoid any conflicts with versions of the programming language and the operating systems. For building golang for fabric v2.5, hyperledger/fabric-ccenv:2.5 can be used For building java for fabric v2.5, hyperledger/fabric-javaenv:2.5 can be used
Alternatively, to build Golang from any other environment the GOOS and GOARCH env variables must be set as follows before/when running the go build command: GOOS=linux GOARCH=amd64 Eg: “GOOS=linux GOARCH=amd64 go build” Note: The GOARCH must be set even building from docker containers if the docker is run on a Mac machine with arm64 architecture or any other machine that is not amd64.
How to Build Binary Formats:
The following articles will help you in building the Binary formats for Java and Golang.
Last updated