这里的智能合约仅包含Init函数和Invoke函数。

为什么一定是这两个方法?

因为在源码中的智能合约模块有这样的接口,如果要完成智能合约的相关编程,就需要实现源码中定义的接口,接口中定义了这两个方法。空口无凭,下面我给大家看一个图:

文件路径:github.com/hyperledger/fabric/core/chaincode/shim

这个文件中的内容如下:

go语言

package main

import (

	"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer"
) var logger = shim.NewLogger("example_cc0") // SimpleChaincode example simple Chaincode implementation
type SimpleChaincode struct { } // Init initializes the chaincode state
func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response { } // Invoke makes payment of X units from A to B
func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response { } func main() {
err := shim.Start(new(SimpleChaincode))
if err != nil {
logger.Errorf("Error starting Simple chaincode: %s", err)
}
}

java语言

package org.hyperledger.fabric.example;

import io.netty.handler.ssl.OpenSsl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hyperledger.fabric.shim.ChaincodeBase;
import org.hyperledger.fabric.shim.ChaincodeStub; public class SimpleChaincode extends ChaincodeBase { private static Log logger = LogFactory.getLog(SimpleChaincode.class); @Override
public Response init(ChaincodeStub stub) { } @Override
public Response invoke(ChaincodeStub stub) { } public static void main(String[] args) {
logger.info("OpenSSL avaliable: " + OpenSsl.isAvailable());
new SimpleChaincode().start(args);
} }

最新文章

  1. web应用程序
  2. Plyr – 简单,灵活的 HTML5 媒体播放器
  3. 编写一个程序,求s=1+(1+2)+(1+2+3)+…+(1+2+3+…+n)的值
  4. 在项目中引用GreenDroid库
  5. 《JavaScript高级程序设计》学习笔记
  6. CodeForces 527B Error Correct System
  7. 20169210《Linux内核原理与分析》第八周作业
  8. C# ,asp.net 获取当前,相对,绝对路径(转)
  9. BT Smart vs ANT+ 技术孰优孰劣?
  10. http状态码及解释
  11. (转)ZXing生成二维码和带logo的二维码,模仿微信生成二维码效果
  12. ssm框架的整合
  13. Linux-KVM虚拟化
  14. LeetCode算法题-Fibonacci Number(Java实现)
  15. mysql的group by查询
  16. jquery 語法
  17. luogu 2294 狡猾的商人 带权并查集
  18. hdoj:2033
  19. 使用SQL Developer导入文件时出现的一个奇怪的问题
  20. in linux system of ftp command

热门文章

  1. 使用html及CSS实现在table中文字信息超过5个隐藏,鼠标移到时弹窗显示全部:
  2. HDU 1251 统计难题 (Trie树模板题)
  3. OpenCV实现图像变换(python)
  4. C++中STL库函数的基本运用
  5. C++用rand()和srand()生成随机数
  6. Flink系统之Table API 和 SQL
  7. vue学习(三)完善模板页(bootstrap+AdminLTE)
  8. iptables服务器主机防火墙
  9. PBFT 算法 java实现(下)
  10. MySQL常用语法总结