1 Star 0 Fork 0

Hyperledger/web3j-openapi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
12个月前
12个月前
12个月前
12个月前
12个月前
12个月前
12个月前
12个月前
Loading...
README

Web3j Open API

Build Status

Web3j-OpenAPI is a OpenAPI client and server generator from Solidity smart contracts. it provides a way to interact with the Ethereum blockchain via simple and intuitive HTTP requests, abstracting the coding layer. These interactions can be done using :

  • Plain HTTP requests
  • Via the Swagger-UI, which is generated with every project
  • A client application using the webj3-openapi-client implementation

The workflow can be summed in the following steps:

  • Writing a Solidity smart contract
  • Generating the corresponding OpenAPI project using Web3j-OpenAPI
  • Running the generated project as a standalone server
  • Sending HTTP requests using Swagger-UI, client application or Curl request.

Getting started with Web3j-OpenAPI

To generate an OpenAPI project using the Web3j-OpenAPI generator, you need to have the Web3j-CLI installed on your machine. It’s easy to do (for Windows instructions head here):

$ curl -L get.web3j.io | sh

Create a Hello World project

To create a base OpenAPI project using a Hello World contract, run the following :

$ web3j openapi new

You can also generate a Web3j-OpenAPI project using the Web3j-OpenAPI-gradle-plugin.

Configure the project

After having the generated project, you can configure your application with the following environment variables:

$ export WEB3J_ENDPOINT=<link_to_your_Ethereum_node>
$ export WEB3J_PRIVATE_KEY=<your_private_key>
$ export WEB3J_OPENAPI_HOST=localhost
$ export WEB3J_OPENAPI_PORT=9090

Run the project

If you aren't using the Web3j-CLI you may run the project using the following Gradle target:

$ cd <project_folder>
$ ./gradlew run

Then, you should be seeing the server logs.

Interact with the project

SwaggerUI

The easiest way to interact with the generated project is via the generated Swagger-UI which can be found on http://<host>:<port>/swagger-ui.

image

Web3j-OpenAPI client

Also, you can use our client implementation via adding the following dependency to your project:

dependencies {
    implementation "org.web3j.openapi:web3j-openapi-client:4.12.2"
}

Then, within the application:

val service = ClientService("http://localhost:9090")
val app = ClientFactory.create(<AppNameApi>::class.java, service)

// Then you have access to all the API resources
val receipt = app.contracts.contractName.deploy()

println("Deployment receipt: ${receipt.contractAddress}")

// ...

For more information, please refer to the documentation.

空文件

简介

OpenAPI compliant service generator for Solidity Smart contracts 展开 收起
取消

发行版

暂无发行版

近期动态

12个月前同步了仓库
12个月前同步了仓库
12个月前同步了仓库
12个月前同步了仓库
12个月前同步了仓库
加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hyperledger/web3j-openapi.git
git@gitee.com:hyperledger/web3j-openapi.git
hyperledger
web3j-openapi
web3j-openapi
main

搜索帮助