Skip to main content
Use these testnet demos to explore the Abelian Java SDK, from account setup and coin tracking to creating, signing, and submitting transactions.
All demos in this document run on the Abelian testnet, a separate blockchain used for testing. The built-in accounts already have ABEL and testnet transactions, so you can run the demos without setting up testnet accounts or sending ABEL to them.

1. Prepare the environment

1.1. Get the demos

Download and decompress abec4j-demo-x.y.z.zip to get the demo directory abel4j-demo. Go to the demo directory and we will run all the demos from there.

1.2. Test Java environment

Run the following command to test if your Java environment is ready for the demos.
The expected output should be like this:
As shown above, run bin/abel4j-demo without any arguments will list all the available demos.

1.3. Test native library

The Abelian SDK for Java depends on a native library libabelsdk built from the Abelian SDK for Go. The native library binaries for all supported platforms (libabelsdk.so.x for Linux,libabelsdk.x.dylib for macOS) are already included in the SDK jar file abel4j-x.y.z.jar. As of the time of writing, the native library is built for the following platforms:
  • Linux x86
  • Linux arm64
  • MacOS x86
  • MacOS arm64 (Apple Silicon)
The SDK jar file contains all the above native libraries for the supported platforms. When you run the demos, the SDK will automatically load the native library compatible with your platform. Run the following command to test if the native library included in the SDK jar file is compatible with your platform.
The expected output should be like this:
If the Crypto demo runs successfully, then the native library included in the SDK jar file is compatible with your platform. Note that this demo is for testing purpose only. It invokes low-level cryptographic APIs of the native library which is unlikely to be used directly in your applications. Therefore, it doesn’t matter if you don’t understand the output here or its source code. The only important thing is whether the demo runs successfully.

1.3 Test the default Abec full node for the demos

The Abelian SDK for Java depends on an Abec full node to access the data on the Abelian blockchain. In the default settings, the demos will connect to an Abec full node maintained by the Abelian Foundation. It allows you to run the demos without setting up your own Abec full node. Note that the default Abec full node is for testing purpose only. It is not stable and may be reset at any time. For production use, you should always set up your own Abec full node for real-world applications. Run the following command to test if the default Abec full node is accessible from your machine.
The expected output should be like this:
If the AbecRPCClient demo runs successfully, then the default Abec full node is accessible from your machine.
Milestone If you have reached this point, congratulations! You have successfully installed the Abelian SDK for Java and tested if it is working properly. You can now learn how to use the SDK to develop your own applications. In the following section, we will omit some output of the demos for brevity. You can run the demos yourself to see the full output.

2. Understand account in Abelian SDK

2.1 Concepts

An account in the Abelian SDK (both for Java and Go) consists of the following components:
  • Private Key: A 132-byte random data used to generate all other keys and addresses of the account. It is the only thing you need to back up for an account. You can use the same seed to restore the account. It is also referred to as Crypto Seed in the low-level APIs of the Abelian SDK.
  • Spend Key: A 1540-byte secret key to sign transactions and should be treated as sensitive as the private key. However, we don’t need to back it up as it can be derived from the private key.
  • Serial Number Key: A 1060-byte semi-secret key to decode which input coins are actually spent in a transaction. It can be derived from the private key.
  • View Key: A 2408-byte semi-secret key to decode the amount of ABELs in the output coins belonging to the account. It can be derived from the private key.
  • Abel Address: A 10696-byte address to receive ABELs. We often referred to it as Address for short. It can be derived from the private key.
  • Short Address: A 66-byte address to receive ABELs. It is calculated from the abel address and can be used as a shorter alternative to the lengthy abel address. Note that a short address must be registered on the Abelian Name Service (ANS) before it can be used to receive ABELs.
  • Fingerprint: A 32-byte fingerprint of the account. It is calculated from the abel address and is part of the short address (from byte 3 to byte 34). We can use the fingerprint as an unique identifier of the account (aka Account ID) because it can be extracted from both the abel address and the short address. However, in this document, we will keep using the short address as the Account ID for consistency.
Note Serial Number Key or View Key are called semi-secret keys because revealing them to untrusted parties will only compromise the privacy of the account. The funds in the account are safe as long as the Spend Key and the Private Key is not revealed. For trusted parties (e.g., an internal Abelian Super Node), the serial number key and the view key can be revealed to them to allow them to track the spent coins and the balance of the account. In this sense, they can be treated as public keys. In the SDK, an account with the secret keys (i.e., private key and spend key) is called a signer account; an account without the secret keys is called a viewer account.

2.2. Create, import and export accounts

The Account demo shows how to create, import and export accounts:

2.3. Built-in accounts

There are 10 built-in accounts that will be used in the following demos. Their addresses are exported to $HOME/.abel4j/accounts by the Account demo. The exported file for an account has an .abeladdress extension which can be loaded by the Abelian Desktop Wallet Legacy for specifying the receiver when sending ABELs. Each file contains two lines with the first line being the abel address and the second line being the short address. The built-in accounts will be used in the following demos illustrating the key functionalities required by a non-trivial application (e.g., an exchange wallet).

3. Separate cold data and hot data to support offline signing

3.1. Initialize wallet databases

The WalletDB demo shows how to initialize wallet databases:
If you haven’t run other demos that may change the databases, the output should be like this:
The WalletDB demo creates two wallet databases in sqlite3 format under $HOME/.abel4j: a cold database named demo-testnet-cold-wallet.db and a hot database named demo-testnet-hot-wallet.db. You may use any sqlite3 GUI client or the sqlite3 command to view the content of the databases.

3.2. Cold Database

The cold database only stores the private keys of the managed accounts for offline signing. It contains only one table signer_account:
The truncated output of the above query is:
In the signer_account table, the shortAddressHex column serves as the account ID and the privateKeyHex column serves is the private key of the account. Other information of an account will be derived on the fly from the private key when needed.

3.3. Hot Database

The hot database stores all the data excluding secret keys of the managed accounts for online operations such as scanning UTXOs, tracking spent coins, generating unsigned raw transactions, etc. It contains three tables viewer_account, coin and tx:
The viewer_account table stores all information but the secret keys of the managed accounts. The schema of the other two tables will be explained when they are used in the following demos.

4. Manage coins in the hot wallet

4.1. Search blocks for viewable coins

The ScanCoins demo shows how to scan for coins belonging to the accounts managed by the hot wallet:
We choose the above range of block heights because we know in advance that they contain some transactions that send ABELs to the built-in accounts. The ScanCoins demo will scan the blocks in the specified range and store the coins belonging to the managed accounts in the hot wallet database. Let’s check the status of the hot wallet database after running the ScanCoins demo:
The output should be like this:
We can see that the ScanCoins demo has scanned 6 blocks and found 1 coin belonging to the managed accounts. Let’s further check the content of the coin table:
The output of the above query is (truncated):
We define Coin ID as the combination of the txid and the vout index of a coin in hex format. The definition ensures that each coin has a unique ID and can be easily located by the ID. To understand the meaning of the fields, let’s take a closer look at the first coin: it bloings to one of the built-in accounts (ABE31C80...FC8A337C), has a value of 1.9103083 ABELs (19,103,083 Neutrinos), is in block 5116 and is not being detected as spent yet. We now scan another range of blocks to see if there are more coins belonging to the managed accounts:
It is supposed to find another 2 coins. Let’s check the status of the hot wallet database again:
The output should be like this:
Note We can scan the same blocks multiple times without worrying about duplicate coins. The ScanCoins demo will only add new coins to the database and ignore the duplicate ones. You may verify this by running the following commands to see if the number of coins in the hot wallet database changes:

4.2. Track spent coins

At this point, the isSpent field of all the coins in the hot wallet database is still 0(false) because we haven’t scanned the blocks that contain the transactions spending the coins. The TrackSpentCoins demo shows how to track the spent coins:
The output should be like this:
We can see that there is 1 coin spent in block 9398. Let’s check the coin table again:
The output of the above query is:
We can see there is 1 coin previously found in block 5116 are now marked as spent. The isSpent field of the other coins remain unchanged.

5. Make a transaction

Making a transaction is non-trivial task. It involves many steps such as selecting coins to spend, calculating the change, generating the raw transaction, signing the raw transaction, broadcasting the signed transaction, etc. However, it is pretty easy to make a transaction with our crafted demos.

5.1. Generate an unsigned raw transaction

The GenerateUnsignedRawTx demo shows how to generate an unsigned raw transaction:
Note Please record the value of txMd5 in the output for later use.
It will generate an unsigned raw transaction with 2 inputs and 2 outputs. The input coins are selected from the coins in the hot wallet database where the isSpent field is 0(false). The output coins are generated by the demo itself. Specifically, the receiver addresses are randomly chosen from the built-in accounts and the total output value is calculated by summing up the values of the input coins and subtracting the transaction fee from it. The generated unsigned raw transaction will be saved in the tx table of the hot wallet database. Let’s check the status of the hot wallet database after running the GenerateUnsignedRawTx demo:
The output should be like this:
Note that the count of records in the tx table is 1 now. Let’s check the content of the tx table:
The output of the above query is like this (you may see different values):
If you have recorded the value of txMd5 in the output of the GenerateUnsignedRawTx demo, you can verify that it is the same as the value in the tx table. We can also see that the value of unsignedRawTxDataHex is not empty and the value of signedRawTxDataHex is empty. This is because the signed raw transaction is not generated yet.

5.2. Sign the unsigned raw transaction

The GenerateSignedRawTx demo shows how to sign the unsigned raw transaction generated by the GenerateUnsignedRawTx demo:
The output should be like this (it’s unlikely to be the same as yours):
We pass the txMd5 as the argument to the demo. It will be used to find the unsigned raw transaction in the tx table. The demo will sign the transaction and save the signed data back to the tx table. Let’s check the status of the hot wallet database after running the GenerateSignedRawTx demo:
Now the output of the above query is like this (you may see different values):
We can see that the value of signedRawTxDataHex is not empty now.
Note The transaction was signed by the spend keys of the senders (who owns the input coins). The spend keys are generated on-demand from the private keys stored in the cold wallet database. The private keys are never exposed to the public network. This is how the cold wallet database protects the private keys from being stolen.

5.3. Broadcast the signed raw transaction

The last step is to broadcast the signed raw transaction to the Abelian network. The SubmitSignedRawTx demo shows how to broadcast the signed raw transaction generated by the GenerateSignedRawTx demo:
If the transaction is successfully submitted, please record the value of txid in the output and search it on the Abelian Explorer to see if it is confirmed. You may also check the tx table to see if the isSubmitted field of the transaction is set to 1(true). If the transaction fails to be submitted, please check the error message in the output. The most common error is that one or more coins in the inputs are spent before the transaction is submitted. If you know at which block height the coins are spent, you can run the TrackSpentCoins demo to update the isSpent field of the coins in the hot wallet database and try to make another unsigned raw transaction, sign it and submit it again.

6. Summary

In this document, we have learned how to install the Abelian SDK for Java, test if it is working properly, understand the concepts of account in the Abelian SDK, separate cold data and hot data to support offline signing, manage coins in the hot wallet and make a transaction with the crafted demos. There are other demos in the SDK that are not covered in this document. You may run them yourself to see the results. You may also read the source code of the demos to learn how to use the SDK to develop your own applications.
Last modified on November 11, 2026