Using Aion: Web3 Console

The Web3 allows for you to interact with your Aion accounts, including checking your account listing, balances, and transfer Aion.

After successfully setting up your Aion node, you can start using Aion using the Web3 console. The Web3 console facilitates the usage of Web3 application programming interface on top of the Aion network. Sample operations that may be performed include:

Prerequisites

The following are the prerequisites for building Aion Web3 API. You can download and install each item by following the provided link:

Run the Web3 Console

  1. Navigate to the aion directory
  2. Open a terminal and run the node using:
./aion.sh
  1. Navigate to the web3 folder
  2. Open a new terminal and run the console using:
node console.js

(If the above command does not work, try npm install first)

🚧

Web3 Console

You must run the following commands through the Web3 Console

View Local Accounts

  1. Run the Web3 console
  2. Run the command:
personal.listAccounts

Check Balance

  1. Run the Web3 console
  2. Run the command:
eth.getBalance('{0xacc}').toString()

Unlock Account

In order to make a transaction (either manually on terminal or through a smart contract), the sender should first unlock their account.

  1. Run the Web3 console
  2. Run the command:
personal.unlockAccount('{0xacc}', '{pw}', {secondsToUnlock})
PlaceholderInformation
{0xacc}account address
{pw}associated account password
{secondsToUnlock}unlock duration in milliseconds

Example:

personal.unlockAccount('0xa012341234123412341234123412341234123412341234123412341234123412', 'abc', 60000)

Transfer Aion

You can send a transaction from one account to another with a specified value. The account of sender should be unlocked before making the transfer.

  1. Run the Web3 console
  2. Unlock your (sender) account
  3. Run the command:
eth.sendTransaction({from:'{0xacc_from}',to:'{0xacc_to}',value: {amount_to_transfer}})
PlaceholderInformation
{0xacc_from}sender’s unlocked account address
{0xacc_to}recipient’s account address
{amount_to _transfer}amount to transfer (note that the denomination for amount is (no. of aion)*1018)

Example (transfer 10 AION):

eth.sendTransaction({from:'0xa012341234123412341234123412341234123412341234123412341234123412',to:'0xabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd',value:10000000000000000000})

🚧

Create Wallet Backup or Import Account

We recommend you keep track of your keystore files and copy them over to the new binary to successfully import/export accounts.

📘

JSON-RPC

Aion currently uses the same JSON-RPC API as Ethereum. The listing of possible commands can be found here.

Obtain Private Key

You may wish to obtain the private keys of your accounts on a previous aion build to import into the Aion Desktop Wallet.

🚧

Warning

Be cautious of where you paste/store private keys - they will give access to your accounts.

  1. Open terminal and navigate to your aion folder and get a list of all your accounts by running:
./aion.sh -a list
  1. As output, you will get the list of public keys for your accounts, for example:
0xa0abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdab
0xa012341234123412341234123412341234123412341234123412341234123412
  1. Obtain the private key associated with each account you want to export, by executing the command (using the public key):
./aion.sh -a export 0xa0abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdab
  1. You will be prompted to input the password for that account, and then your private key will be displayed:
Please enter your password: 
Your private key is: 0xabcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234