Skip to content

Quick Start with embedded AVM

Satya edited this page Oct 16, 2019 · 20 revisions

This document provides the quickest way to try development on embedded AVM. Some of the details are skipped to keep this document small. For detailed user guide, please refer to Aion4j Maven Plugin User Guide

Pre-requisites

  1. Java 10 and above
  2. Maven 3.5.4 and above

1. Create AVM java project

The fastest way to create a AVM project is using a maven archetype - avm-archetype.

Run the following maven command to create an AVM project.

$> mvn archetype:generate -DarchetypeGroupId=org.aion4j -DarchetypeArtifactId=avm-archetype -DarchetypeVersion=0.30

Follow the instruction to enter groupId, artifactId and package information.

2. Edit pom.xml

Edit pom.xml file in the generated project and change <aion4j.maven.plugin> version to the latest release version. Please refer to aion4j maven plugin project page for the latest release version.

<properties>
  ...
   <aion4j.plugin.version>x.x.x</aion4j.plugin.version>
  ...
</properties>

3. Initialize and copy required AVM libraries

$> mvn initialize

4. Build the project

$> mvn clean install

Using Embedded AVM

1. Deploy your first AVM smart contract in an embedded AVM

$> mvn aion4j:deploy

2. Call a method in the smart contract

The archetype generated project comes with a sample java smart contract. To invoke "greet" method in the sample contract, run the aion4j:call maven goal.

$> mvn aion4j:call -Dmethod=greet -Dargs="-T AVM"

3. Get the balance

To get the balance of the default address.

$> mvn aion4j:get-balance