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.
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.
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)
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
)
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.
To build and run the unit tests:
-
Clone this repository:
git clone [email protected]:web3j/web3j-aion.git
-
Change directory to the cloned repository:
cd web3j-aion
-
Run the Gradle
build
task:./gradlew build
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
2-dimensional arrays are not currently supported but we are working in a web3j release to address that.