Building smart contracts
ICON can only run your smart contract after it has been compiled down into bytecode.
You need to install JDK 11 or later version. Visit OpenJDK.net for prebuilt binaries. Or you can install a proper OpenJDK package from your OS vendors.
$ brew tap AdoptOpenJDK/openjdk
$ brew cask install adoptopenjdk11
In Linux (Ubuntu 18.04):
$ sudo apt install openjdk-11-jdk
For example, using the hello-world sample in the ICON smart contract examples:
$ ./gradlew build
The compiled jar bundle will be generated at
You need to optimize your jar bundle before you deploy it to local or ICON networks. This involves some pre-processing to ensure the actual deployment successful.
gradle-javaee-pluginis a Gradle plugin to automate the process of generating the optimized jar bundle. Run the
optimizedJartask to generate the optimized jar bundle.
$ ./gradlew optimizedJar
The output jar will be located at
You can get an ICON smart contract's ABI by using the
icx_getScoreApifunction from the JSON-RPC API. See the ABI specification listed there in the Returns descriptor.