Skip to content

Instantly share code, notes, and snippets.

@chevdor
Created June 7, 2017 22:49
Show Gist options
  • Save chevdor/6d0628703c63a9866289d5e85e51ff11 to your computer and use it in GitHub Desktop.
Save chevdor/6d0628703c63a9866289d5e85e51ff11 to your computer and use it in GitHub Desktop.
Java minimalist chaincode
/**
* Created by will on 07.06.17.
*/
import org.hyperledger.java.shim.ChaincodeBase;
import org.hyperledger.java.shim.ChaincodeStub;
/**
* <h1>Hello Blockchain sample chaincode</h1>
* (java implementation of <A href="https://github.com/hyperledger/fabric/blob/master/examples/chaincode/go/chaincode_example02/chaincode_example02.go">chaincode_example02.go</A>)
*
* @author Wilfried Kopp [email protected]
*/
public class Hello extends ChaincodeBase {
public static void main(String[] args) throws Exception {
Hello instance = new Hello();
System.out.println("Starting chaincode " + instance.getChaincodeID());
instance.start(args);
}
@Override
public String run(ChaincodeStub stub, String function, String[] args) {
return null;
}
public String init(ChaincodeStub stub, String function, String[] args) {
return null;
}
@Override
public String query(ChaincodeStub stub, String function, String[] args) {
return null;
}
@Override
public String getChaincodeID() {
return "Hello";
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>hello_blockchain</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.hyperledger</groupId>
<artifactId>shim-client</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment