Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
/ web3j-aion Public archive

web3j integration with the Aion network

License

Notifications You must be signed in to change notification settings

web3j/web3j-aion

Repository files navigation

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.