区块链服务 BCS-链代码结构:链代码接口

时间:2025-02-12 14:55:25

链代码接口

Fabric架构版本的 区块链 实例:

  • 链代码启动必须通过1.4风格(调用shim包)中的Start函数,入参为shim包中定义的Chaincode接口类型。实际开发中, 您需要自行定义一个结构体,实现Chaincode接口。
    type Chaincode interface {    Init(stub ChaincodeStubInterface) pb.Response    Invoke(stub ChaincodeStubInterface) pb.Response  }
  • 2.2风格(使用fabric-contract-api-go包)的链代码实际开发中, 您需要自行定义一个结构体,实现Chaincode接口。
    type Chaincode interface {        Init(ctx contractapi.TransactionContextInterface, args…) error        Invoke(ctx contractapi.TransactionContextInterface, args…) error  }
support.huaweicloud.com/devg-bcs/bcs_devg_2002.html