Creating a contract
We are now ready to start implementing our contracts. We will focus on code examples from ExportLicenseContract
implemented in Java and TradeContract
implemented in Node.js.
Full documentation of Java and Node.js Contract APIs are available at:
- https://hyperledger.github.io/fabric-chaincode-java/
- https://hyperledger.github.io/fabric-chaincode-node/master/api/index.html
The contract interface
Every contract must implement the ContractInterface
, whose methods are called in response to the received transaction proposals.
In Java, the ContractInterface
is defined in the org.hyperledger.fabric.contract
package and shown in the following code:
package org.hyperledger.fabric.contract;
public interface ContractInterface {
default Context createContext(final ChaincodeStub stub);
default void unknownTransaction(final Context ctx);
default void beforeTransaction(final Context ctx);
default void afterTransaction...