How to deploy and test system chaincodes on Hyperledger Fabric effectively

Rahul Mahadev
Feb 7, 2019 · 4 min read
Image for post
Image for post
package mainimport (
“fmt”
“github.com/hyperledger/fabric/core/chaincode/shim”
pb “github.com/hyperledger/fabric/protos/peer”
)
// New returns an implementation of the chaincode interface.
func New() shim.Chaincode {
fmt.Println(“Hello”)
peer1org1, err := net.LookupHost("peer1.org1.example.com")
if err != nil {
log.Fatalf("net.LookupHost peer1.org1.example.com failed with %s\n", err)
}
fmt.Println(peer1org1)
return &helloworldscc{}
}
type helloworldscc struct{}// Init implements the chaincode shim interface
func (s *helloworldscc) Init(stub shim.ChaincodeStubInterface) pb.Response {
return shim.Success(nil)
}
// Invoke implements the chaincode shim interface
func (s *helloworldscc) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
return shim.Success(nil)
}
go build -buildmode=plugin
docker run -i --rm  -v PATH_TO_PLUGIN:/opt/gopath/src/github.com/PLUGIN_NAME -w /opt/gopath/src/github.com/PLUGIN_NAME \
-v PATH_TO_FABRIC:/opt/gopath/src/github.com/hyperledger/fabric \
hyperledger/fabric-baseimage:amd64-0.4.14 \
go build -buildmode=plugin -tags
system:
cscc: enable
lscc: enable
escc: enable
vscc: enable
qscc: enable
helloworldscc: enable

systemPlugins:
- enabled: true
name: helloworldscc
path: /opt/lib/helloworld.so
invokableExternal: true
invokableCC2CC: true
GO_TAGS+=" pluginsenabled" make peer
DOCKER_DYNAMIC_LINK=true GO_TAGS+=" pluginsenabled" make peer-docker
Image for post
Image for post
Click to Read today’s top story

Coinmonks

Coinmonks is a non-profit Crypto educational publication.

By Coinmonks

A newsletter that brings you week's best crypto and blockchain stories and trending news directly in your inbox, by CoinCodeCap.com Take a look

Create a free Medium account to get Crypto News in your inbox.

Rahul Mahadev

Written by

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Rahul Mahadev

Written by

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store