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:
- node.js version 8.9.1 download and install
- npm version 5.5.1 (typically included with node.js installation.)
- gulp version 3.9.1 download and install
Run the Web3 Console
- Navigate to the aion directory
- Open a terminal and run the node using:
./aion.sh
- Navigate to the web3 folder
- 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
- Run the Web3 console
- Run the command:
personal.listAccounts
Check Balance
- Run the Web3 console
- 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.
- Run the Web3 console
- Run the command:
personal.unlockAccount('{0xacc}', '{pw}', {secondsToUnlock})
Placeholder | Information |
---|---|
{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.
- Run the Web3 console
- Unlock your (sender) account
- Run the command:
eth.sendTransaction({from:'{0xacc_from}',to:'{0xacc_to}',value: {amount_to_transfer}})
Placeholder | Information |
---|---|
{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.
- Open terminal and navigate to your aion folder and get a list of all your accounts by running:
./aion.sh -a list
- As output, you will get the list of public keys for your accounts, for example:
0xa0abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdab
0xa012341234123412341234123412341234123412341234123412341234123412
- 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
- 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
Updated over 6 years ago