查询合同Java API Hyperledger面料
我正在分析Hyperledger面料中的Fabcar Java项目。 以下是项目的依赖项。来自pom.xml的摘要
<dependencies>
<dependency>
<groupId>org.hyperledger.fabric</groupId>
<artifactId>fabric-gateway-java</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.4.2</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.12.2</version>
<scope>test</scope>
</dependency>
我能够在其中运行程序。像
EnrollAdmin.main(null);
RegisterUser.main(null);
ClientApp.main(null);
那时,我想从头开始写自己的智能合约。因此,开始研究/分析并偶然发现
;主持人说,这段视频必须从合同课程中延长。 合同类包含
beforeTransaction()
afterTransaction()
createContext()
诸如等的
方法,因此我在Java工作区中搜索了合同类,并在其中发现了不同的方法。 例如
Transaction createTransaction(String name);
submitTransaction(String name, String... args)
evaluateTransaction(String name, String... args)
,我的问题
已升级合同课程,我正在看旧教程,或者我指的是旧的API?
-
我还发现,有一个依赖性织物 - 链轴 - 链2.2.4 API,其中包含与视频教程匹配的方法。
软件包:org.hyperledger.fabric.contract
接口:ContractInterface
我是否必须导入此依赖项或我现有的合同接口(org.hyperledger.fabric.gateway.contract)才能编写新的智能合约?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编写面料应用程序有两个编码方面。一个是智能合约(也称为链代码)。另一个是客户端应用程序,该应用程序将发送交易请求,从而导致正在执行的智能合约中的功能。
首先进行SmartContract,这将扩展合同接口,然后您将编写各种事务功能(例如CreateEasset)。
要“运行”这些事务功能,客户端应用程序需要调用提交或评估事务。只有在提交事务功能时,才会更改为分类帐。因此,评估实际上只是一个查询。
总而言之,您需要使用两个API-一个用于合同,一个用于客户申请。
There are two coding aspects to writing an application for Fabric. One is the Smart Contract (also referred to as chaincode). The other is the client side application that will send in transaction requests that result in functions in the Smart Contract being executed.
Taking the SmartContract first, that will extend the Contract Interface, and then you'll write various transaction functions (for example createAsset).
To 'run' these transaction functions a client application needs to call submit or evaluate transaction. Only if a transaction function is submitted will changes be made to the ledger. Evaluate is therefore really just a query.
In summary there are two APIs that you need to use - one for the Contract and one for the Client Application.
createContext(),beforetransaction()和transaction()方法是Hyperledger织物 contractapiapi 。这些方法可用于链码。 createTransAction(),submittransaction()和evaluateTransaction()是应用程序网关。应用程序网关软件包用于与织物网络进行交互。您可以使用应用程序网关调用/查询链条。两者的样本都在。
createContext(), beforeTransaction() and afterTransaction() methods are part of the Hyperledger Fabric contractapi. These methods are available to use in chaincode. createTransaction(), submitTransaction() and evaluateTransaction() are part of the application gateway. Application gateway package is used to interact with the Fabric network. You can invoke/query chaincode using application gateway. Samples for both are available in fabric-samples. For more information, refer official documentation.