查询合同Java API Hyperledger面料

发布于 2025-02-10 11:31:03 字数 2088 浏览 1 评论 0 原文

我正在分析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)

,我的问题

  1. 已升级合同课程,我正在看旧教程,或者我指的是旧的API?

  2. 我还发现,有一个依赖性织物 - 链轴 - 链2.2.4 API,其中包含与视频教程匹配的方法。

    软件包:org.hyperledger.fabric.contract

    接口:ContractInterface

我是否必须导入此依赖项或我现有的合同接口(org.hyperledger.fabric.gateway.contract)才能编写新的智能合约?

I am analyzing the Fabcar Java Project in Hyperledger Fabric.
Below are the dependencies in project. snippet from 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>

I am able to run the Programs in it. like

EnrollAdmin.main(null);
RegisterUser.main(null);
ClientApp.main(null);

Then I wanted to write my own smart contract from scratch.so started research/analysis and stumbled upon
Video By Hyperledger Foundation

here in this video , presenter said every smart contract has to extend from Contract class.
Contract class contains methods like

beforeTransaction()
afterTransaction()
 createContext()

etc

so I searched Contract class in my Java workspace and found different methods present in it.
such as

Transaction createTransaction(String name);
submitTransaction(String name, String... args) 
evaluateTransaction(String name, String... args)

So my questions

  1. has Contract class upgraded and I am watching old tutorials or I am referring to OLD APIs ?

  2. Also I found that , there is a dependency fabric-chaincode-shim 2.2.4 API, which contains the methods which matches with Video tutorial.

    package: org.hyperledger.fabric.contract

    interface: ContractInterface

Do i have to import this dependency or my existing Contract interface(org.hyperledger.fabric.gateway.Contract) enough to write a new smart contract?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终陌 2025-02-17 11:31:04

编写面料应用程序有两个编码方面。一个是智能合约(也称为链代码)。另一个是客户端应用程序,该应用程序将发送交易请求,从而导致正在执行的智能合约中的功能。

首先进行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.

云胡 2025-02-17 11:31:04

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文