GithubHelp home page GithubHelp logo

isabella232 / web3j-openapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from web3j/web3j-openapi

0.0 0.0 0.0 1.15 MB

OpenAPI compliant service generator for Solidity Smart contracts

Home Page: https://www.web3labs.com/epirus

Kotlin 46.24% Shell 0.80% Solidity 49.61% Mustache 3.36%

web3j-openapi's Introduction

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 Epirus-CLI installed on your machine (Note - the Epirus CLI has replaced the Web3j CLI). It’s easy to do (for Windows instructions head here):

$ curl -L get.epirus.io | sh

Create a Hello World project

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

$ epirus 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 use the Epirus-CLI to run it using the following command (Note: You will need to create an Epirus Account).

$ epirus login
$ epirus run rinkeby|ropsten

Alternatively, 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 Epirus-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.7.1"
}

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.

web3j-openapi's People

Contributors

alexandrour avatar cleanunicorn avatar conor10 avatar iikirilov avatar rach-id avatar xaviarias avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.