2

I want to write a chaincode in JAVA. Can I use eclipse? How can I write and test the chain code? It is my first time to learn how to develop chaincodes for Fabric. I know JAVA and I know how to write smart contracts for Ethereum where I use Remix.

Any help is appreciated. Is there a way to write and test the chaincode in JAVA without creating a network? as in just like in Remix..

ESCoder
  • 15,431
  • 2
  • 19
  • 42
Haya Raed
  • 5,921
  • 5
  • 16
  • 19

1 Answers1

0

Can I use eclipse?

You can use your favorite editor, is just Java what you are writing.

How can I write and test the chain code?

Follow the examples on the java chaincode repo, depending on what version of fabric you are using checkout to a branch or another. Take on account that there is a big difference between the version 1.X and 2.X . The examples that they provide are very good and you can use maven or gradle. To test the chaincode you can write unit testing with Junit and mock the shim.

Take on account that the chaincode is going to be embeded on a docker container, debugging is done by logging, so you will need to log a lot.

Is there a way to write and test the chaincode in JAVA without creating a network

Use unit testing before deploying the chaincode, unit testing here is the most important thing. The shim what it does is going to write and read so the logic that goes inside is the most important part. To testing on "real" mode you will need a network, it does not need to be big, with any example networks that are provided with the examples repo will be more than enough.

Bentipe
  • 423
  • 3
  • 17