Git Product home page Git Product logo

web3j-aion's Introduction

Archive Notice

This project is no longer under active development and has been archived. The repository is kept for historical purposes and read-only access. No further updates or pull requests will be considered.

web3j Aion

web3j Aion integration Build Status

This project integrates web3j with the Aion network. It enables the deployment and invocation of Aion smart contracts from your Java code using web3j contract wrappers.

It is composed by the following modules:

  • AVM: Contains the encoder and decoder for interoperability with the Aion Virtual Machine.
  • Code generation: Provides a CLI for contract wrapper generation from the ABI and binaries.
  • Common: Contains common functionality like transaction signing and JSON-RPC implementation.

Quick start

The API starting point is the org.web3j.aion.protocol.Aion class. It implements the standard Ethereum JSON-RPC endpoints (eth_call, ethGetBalance, ...) with some Aion-specific features, as well as the administration endpoints (personal_NewAccount, ...).

To instantiate and start using it, create a service pointing to a node (http://localhost:8545 by default):

val service = HttpService()

then create an Aion instance and you start calling the API endpoints:

val aion = Aion.build(service)
aion.ethGetBalance("0x...", DefaultBlockParameterName.LATEST)

Sending signed transactions

Transactions can be signed locally and sent with the AionTransactionManager class.

val manager = AionTransactionManager(
    aion, Ed25519KeyPair("your private key")
)

// Default NRG and value
manager.sendTransaction(
    to = "0x...",
    data = "0x..."
)

To deploy a contract override the default values:

manager.sendTransaction(
    to = "0x...",
    data = "0x...",
    constructor = true,
    nrgLimit = AionConstants.NRG_CREATE_CONTRACT_DEFAULT
)

Generating contract wrappers

To learn how to use the CLI to generate contract wrappers, refer to the code generation module.

You can also checkout the sample repository to start with a configured Gradle project.

Building and testing

To build and run the unit tests:

  1. Clone this repository:

    git clone [email protected]:web3j/web3j-aion.git
  2. Change directory to the cloned repository:

    cd web3j-aion
  3. Run the Gradle build task:

    ./gradlew build

Integration tests

Before running the integration tests, check that your Docker version is at least 1.6.0 and you have more than 2GB of free disk space. To run the integration tests use the command:

./gradlew integrationTest

Work in progress

2-dimensional arrays are not currently supported but we are working in a web3j release to address that.

web3j-aion's People

Contributors

antonydenyer avatar iikirilov avatar nicksneo avatar xaviarias avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

web3j-aion's Issues

Issue with CLI

The issue is when I run the following command:
./web3j-aion -a gettersetter-1.0-SNAPSHOT.abi -b gettersetter-1.0-SNAPSHOT.jar -o ~/Desktop -p gettersetter

I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/web3j/codegen/SolidityFunctionWrapperGenerator at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at org.web3j.aion.codegen.AionGenerator$CommandLineRunner.run(AionGenerator.kt:108) at picocli.CommandLine.execute(CommandLine.java:817) at picocli.CommandLine.access$700(CommandLine.java:111) at picocli.CommandLine$RunLast.handle(CommandLine.java:994) at picocli.CommandLine$RunLast.handle(CommandLine.java:962) at picocli.CommandLine$AbstractParseResultHandler.handleParseResult(CommandLine.java:870) at picocli.CommandLine.parseWithHandlers(CommandLine.java:1153) at picocli.CommandLine.run(CommandLine.java:1490) at picocli.CommandLine.run(CommandLine.java:1424) at org.web3j.aion.codegen.AionGeneratorMain$Companion.main(AionGenerator.kt:160) at org.web3j.aion.codegen.AionGeneratorMain.main(AionGenerator.kt) Caused by: java.lang.ClassNotFoundException: org.web3j.codegen.SolidityFunctionWrapperGenerator at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 20 more

Looks like it can't find the .abi file but the files exist in the same folder as the executable.

Using version https://github.com/web3j/web3j-aion/releases/tag/v4.5.7

Happens on macOS Catalina and Ubuntu 18

@xaviarias @iikirilov @antonydenyer

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.