crypto.bi
Ad:
Stop posting for free. Get paid for your social media content!
Join Arena App today and get paid in crypto!

ELI5 AvalancheJ Introduction

AvalancheJ is an experimental Java library for exploration and integration with the AVAX ecosystem.

Important – Please Read
Still in its initial development stages, AvalancheJ is pre-Beta software and could contain serious bugs. Please keep in mind it’s an exploratory hobbyist project meant as a learning tool above anything else. For example, if an error occurs during a mainnet token transfer, you could lose those funds. I’ve been working on the Fuji testnet all along, so if you wish to explore AvalancheJ, I highly recommend using test tokens instead.

This article is a work in progress. I’ll be updating it as I develop AvalancheJ, so please bookmark it and come back for the latest features.

AvalancheJ Library Structure

Where possible, the same structure as Ava Labs official libraries has been preserved.

For example, the to.avax.avalanche package contains much of the same structure found in the AvalancheJS Typescript library. In fact, there’s tons of code literally translated from the AvalancheJS Typescript original, where I maintained the same variable and method names. This should ease the AvalancheJS learning curve.

Typescript uses the export concept, whereas Java has a different access control mechanism. For instance, when a single .ts file exports many Typescript classes, I turned the ts filename into a Java package and created individual classes under it. This is necessary because Java does not have a export concept, allowing several public classes under a single file.

Avalanche Wallet code can be found under to.avax.avalanche.wallet. Keep in mind this is experimental code and may cause losses if there’s a bug. Since this code is based on the official Avalanche Wallet Typescript implementation, I’ve tried, where possible, to preserve package structure and class names. Same idea as the AvalancheJS-based packaging structure described before.

Networked vs. Airgapped

One of the core ideas behind AvalancheJ is separating your crypto from the web browser.

Today, most wallets run on the web, mainly due to web3 integration requirements, but some us would like to run old school wallets and utilities. AvalancheJ runs on the JVM – Java Virtual Machine – which you can run offline.

So, on my AvalancheJ consumer project, AVAX Toolbox, I structured it such that there are separate networked and airgapped functionalities.

The key concept to know here is that AvalancheJ allows you to work offline if you want. For example key generation, new mnemonic generation, transaction creation and signing, should all be doable while offline. This is currently impossible on existing web-browser based solutions

Bootstrapping

P2P systems need a way to find initial peers to connect to. This has always been a challenge with P2P systems like Gnutella and similar.

AvalancheJ uses the same system as AvalancheGo does, by initially connecting to a fixed set of hosts. These are configured under /resources/bootstrappers.json

You can always find the latest bootstrappers.json file under the official AvalancheGO repo.

Licensing

AvalancheJ is FOSS – free as in money and free as in freedom. These are independent hobbyist projects, not sponsored by anyone.

All I ask is that you give credit. A link back to Crypto.bi would be really appreciated 🙂

AvalancheJ and AVAX Toolbox both are licensed under 3-Clause BSD

References

AvalancheJ Github Repo

AVAX Toolbox Github Repo

Official AvalancheGO Sources

AvalancheJS Sources

Avalanche Wallet Sources

About the Author
Published by @rektbuildr - Software developer and technical writer. In charge of fixing the coffee machine at crypto.bi. Interest include Java, Avalanche AVAX, C and C++, Spark, Hadoop, Scala language, golang, RedHat OpenShift and kubernetes, container tech, DevOps and related techs. Learn More About Us