Skip to main content
REFERENCE
MAIN CHAIN

Main Chain CLI (ela-cli)

ela-cli is the command-line client shipped with the ELA node. It talks to a running ELA node over JSON-RPC for chain queries, mempool/block inspection, and relaying signed transactions. Local wallet operations (create keystore, build/sign txs) run offline except where noted.

Default JSON-RPC port: 20336 (use your node’s config.json if different; testnet often uses another port).

Global RPC options​

OptionPurpose
--rpcportRPC listen port (default 20336).
--rpcuserHTTP Basic Auth username configured on the node.
--rpcpasswordHTTP Basic Auth password configured on the node.

Example — best height

./ela-cli --rpcport 20336 --rpcuser myuser --rpcpassword mypass info getcurrentheight
301

You can wrap these flags in a small shell script (for example ela-cli.sh) and pass through "$@" so every subcommand uses the same RPC settings.


1. Wallet Management​

Wallet commands use the local keystore file (default ./keystore.dat). Common wallet flags:

  • -w / --wallet — path to the keystore file.
  • -p / --password — password (you can omit and enter when prompted).

Run ./ela-cli wallet -h for the full command list.

1.1 Create Wallet​

Creates a new wallet file with a default account; prints ADDRESS and PUBLIC KEY.

./ela-cli wallet create -p 123
ADDRESS                            PUBLIC KEY
---------------------------------- ------------------------------------------------------------------
ESVMKLVB1j1KQR8TYP7YbksHpNSHg5NZ8i 032d3d0e8125ac6215c237605486c9fbd4eb764f52f89faef6b7946506139d26f8
---------------------------------- ------------------------------------------------------------------

1.2 View Public Key​

./ela-cli wallet account -p 123
ADDRESS                            PUBLIC KEY
---------------------------------- ------------------------------------------------------------------
ESVMKLVB1j1KQR8TYP7YbksHpNSHg5NZ8i 032d3d0e8125ac6215c237605486c9fbd4eb764f52f89faef6b7946506139d26f8
---------------------------------- ------------------------------------------------------------------

1.3 Check Balance​

Requires RPC access (same global --rpcuser / --rpcpassword / --rpcport as your node).

./ela-cli wallet balance
INDEX                            ADDRESS BALANCE                           (LOCKED)
----- ---------------------------------- ------------------------------------------
0 EJMzC16Eorq9CuFCGtyMrq4Jmgw9jYCHQR 505.08132198 (174.04459514)
----- ---------------------------------- ------------------------------------------

1.4 Add Standard Account​

Adds another single-signature account to the keystore.

./ela-cli wallet add
ADDRESS                            PUBLIC KEY
---------------------------------- ------------------------------------------------------------------
ET15giWpFNSYcTKVbj3s18TsR6i8MBnkvk 031c862055158e50dd6e2cf6bb33f869aaac42c5e6def66a8c12efc1fdd16d5597
---------------------------------- ------------------------------------------------------------------

1.5 Add Multi-Signature Account​

./ela-cli wallet addmultisig -m 3 --pks <pubkey1>,<pubkey2>,<pubkey3>,<pubkey4>
  • --pks — Comma-separated list of compressed public keys (hex) that participate in the multisig script.
  • -m — M in M-of-N: minimum number of signatures required to spend. With four keys and -m 3, you have a 3-of-4 multisig (three distinct key signatures must sign a spend).

You are prompted for a wallet password. On success the new multisig address is printed.

8PT1XBZboe17rq71Xq1CvMEs8HdKmMztcP

1.6 Delete Account​

./ela-cli wallet delete <address>

The default account cannot be deleted. After deletion, remaining accounts are listed.

1.7 Export Account​

Exports ADDRESS and PRIVATE KEY (hex) for all accounts in the keystore. Handle output as highly sensitive.

./ela-cli wallet export
ADDRESS                            PRIVATE KEY
---------------------------------- ------------------------------------------------------------------
EJMzC16Eorq9CuFCGtyMrq4Jmgw9jYCHQR c779d181658b112b584ce21c9ea3c23d2be0689550d790506f14bdebe6b3fe38
---------------------------------- ------------------------------------------------------------------

1.8 Import Account​

./ela-cli wallet import <privatekey> -w keystore1.dat

Imports a private key into the given keystore (creates the file if needed). Password prompt applies to the target wallet.

ADDRESS                            PUBLIC KEY
---------------------------------- ------------------------------------------------------------------
EQJP3XT7rshteqE1D3u9nBqXL7xQrfzVh1 03f69479d0f6aa11aae5fbe5e5bfca201d717d9fa97a45ca7b89544047a1a30f59
---------------------------------- ------------------------------------------------------------------

1.9 Generate Deposit Address​

Derives the deposit address used in certain cross-chain / side-chain flows from a standard ELA address.

./ela-cli wallet depositaddr <address>
DVgnDnVfPVuPa2y2E4JitaWjWgRGJDuyrD

1.10 Generate Cross Chain Address​

Derives the locked main-chain cross-chain address for a side chain from that chain’s genesis block hash (64 hex chars).

./ela-cli wallet crosschainaddr <genesis_hash>
XKUh4GLhFJiqAMTF6HyWQrV9pK9HcGUdfJ

2. Transaction Operations​

Built transactions are written to a file (often to_be_signed.txn). Sign before sendtx.

2.1 Build Standard Transaction​

./ela-cli wallet buildtx --to <address> --amount 0.1 --fee 0.01
FlagMeaning
--fromSource address. Default: keystore default account.
--toRecipient address (single output).
--amountAmount to send (ELA).
--feeNetwork fee (ELA).
--outputlockBlock height until which the recipient output cannot be spent (timelock on the UTXO).
--txlockBlock height before which the transaction must not be included in a block (transaction-level lock).
Hex:  0902000100...
File: to_be_signed.txn

2.2 Build Multi-Signature Transaction​

--from must be the multisig address present in your keystore; signers use separate keystores in §2.7.

./ela-cli wallet buildtx --from <multisig_addr> --to <addr> --amount 0.51 --fee 0.001
Hex:
0902000100...
File: to_be_signed.txn

2.3 Build Multi-Output Transaction​

Prepare addresses.csv (one address,amount per line):

EY55SertfPSAiLxgYGQDUdxQW6eDZjbNbX,0.001
Eeqn3kNwbnAsu1wnHNoSDbD8t8oq58pubN,0.002
./ela-cli wallet buildtx --tomany addresses.csv --fee 0.001
Multi output address: EY55SertfPSAiLxgYGQDUdxQW6eDZjbNbX , amount: 0.001
Multi output address: Eeqn3kNwbnAsu1wnHNoSDbD8t8oq58pubN , amount: 0.002
Hex: 0902000100...
File: to_be_signed.txn

2.4 Build Activation Transaction​

Activates a producer that was inactive. The subcommand is producer activate (not a top-level activate).

./ela-cli wallet buildtx producer activate --nodepublickey <pubkey>

If --nodepublickey is omitted, the default account’s public key is used when appropriate. You may be prompted to sign the payload.

Hex:  090d0021...
File: ready_to_send.txn

2.5 Build Voting Transaction​

Put candidate owner public keys in candidates.csv (one key per line).

033b4606d3cec58a01a09da325f5849754909fec030e4cf626e6b4104328599fc7
032895050b7de1a9cf43416e6e5310f8e909249dcd9c4166159b04a343f7f141b5
./ela-cli wallet buildtx vote --for candidates.csv --amount 1 --fee 0.1

--amount is the voting weight (ELA) attributed per the vote construction rules for that transaction type.

candidate: 033b4606d3cec58a01a09da325f5849754909fec030e4cf626e6b4104328599fc7
candidate: 032895050b7de1a9cf43416e6e5310f8e909249dcd9c4166159b04a343f7f141b5
Hex: 0902000100...
File: to_be_signed.txn

2.6 Build Cross Chain Transaction​

  • --saddress — Cross-chain / side-chain lock address on main chain (often from crosschainaddr).
  • --to — Recipient on the side chain.
./ela-cli wallet buildtx crosschain --saddress <side_addr> --to <target_addr> --amount 1 --fee 0.1
Hex:  0908000122...
File: to_be_signed.txn

2.7 Sign Transaction​

Use --hex or -f / --file for raw txn input. Multi-sig: sign sequentially with different -w keystores until [ M / M ].

Standard (single-sig)

./ela-cli wallet signtx -f to_be_signed.txn
[ 1 / 1 ] Transaction successfully signed
Hex: 0902000100...
File: ready_to_send.txn

Multi-sig (example 3-of-3, three keystores)

First signature:

./ela-cli wallet signtx -f to_be_signed.txn -w keystore1.dat
[ 1 / 3 ] Transaction successfully signed
Hex: 0902000100...
File: to_be_signed_1_of_3.txn

Second:

./ela-cli wallet signtx -f to_be_signed_1_of_3.txn -w keystore2.dat
[ 2 / 3 ] Transaction successfully signed
Hex: 0902000100...
File: to_be_signed_2_of_3.txn

Third:

./ela-cli wallet signtx -f to_be_signed_2_of_3.txn -w keystore3.dat
[ 3 / 3 ] Transaction successfully signed
Hex: 0902000100...
File: ready_to_send.txn

2.8 Send Transaction​

./ela-cli wallet sendtx -f ready_to_send.txn
5b9673a813b90dd73f6d21f478736c7e08bba114c3772618fca232341af683b5

The returned value is the transaction id (txid).

2.9 Show Transaction​

Decode a raw transaction from hex or file.

./ela-cli wallet showtx --hex <hex_string>
Transaction: {
Hash: 4661854b9441d52f78f5f4c025b37270af3aaa60332c4bfe041fa3cbc91b0a7e
Version: 9
TxType: TransferAsset
...
Programs: [Program: {
Code: 21034f3a7d2f33ac7f4e30876080d359ce5f314c9eabddbaaca637676377f655e16cac
Parameter: 40433f2f2fa7390db75af3a3288943ce178f9373b2362a3b09530dd30fbb50fa5f...
}]
}

3. Blockchain Info​

Subcommands live under ela-cli info and use the global RPC flags when the node requires authentication.

3.1 getconnectioncount​

./ela-cli info getconnectioncount
1

3.2 getneighbors​

./ela-cli info getneighbors
[
"127.0.0.1:30338 (outbound)"
]

3.3 getnodestate​

./ela-cli info getnodestate
[
{
"Addr": "127.0.0.1:30338",
"ConnTime": "2019-02-28T14:32:44.996711+08:00",
"ID": 4130841897781718000,
"Inbound": false,
"LastBlock": 395,
"LastPingMicros": 0,
"LastPingTime": "0001-01-01T00:00:00Z",
"LastRecv": "2019-02-28T14:32:45+08:00",
"LastSend": "2019-02-28T14:32:45+08:00",
"RelayTx": 0,
"Services": 3,
"StartingHeight": 395,
"TimeOffset": 0,
"Version": 10002
}
]

3.4 getcurrentheight​

./ela-cli info getcurrentheight
395

3.5 getbestblockhash​

./ela-cli info getbestblockhash
"0affad77eacef8d5e69bebd1edd24b43ca8d8948dade9e23b14a9d8ceca060e6"

3.6 getblockhash​

Argument: block height.

./ela-cli info getblockhash 100
"1c1e1c22ce891184d390def30a9b8f15f355c05a7bd6e7e7912b571141e01415"

3.7 getblock​

Pass block hash or decimal height (CLI resolves height to hash, then fetches verbose block JSON).

By hash:

./ela-cli info getblock 1c1e1c22ce891184d390def30a9b8f15f355c05a7bd6e7e7912b571141e01415

By height:

./ela-cli info getblock 100
{
"hash": "1c1e1c22ce891184d390def30a9b8f15f355c05a7bd6e7e7912b571141e01415",
"height": 100,
"confirmations": 296,
"merkleroot": "8570ff4cd3d356be2f9d90333205f9d4b11bd234aa513bf16c53c503f6575718",
"time": 1550721855,
"tx": [
{
"txid": "8570ff4cd3d356be2f9d90333205f9d4b11bd234aa513bf16c53c503f6575718",
"type": 0,
"vout": [
{
"address": "EJMzC16Eorq9CuFCGtyMrq4Jmgw9jYCHQR",
"value": "1.75799086"
}
]
}
]
}

(Output is truncated in this doc; a live node returns the full block object.)

3.8 getrawtransaction​

Argument: transaction id (64 hex).

./ela-cli info getrawtransaction 17296308c322aee00274da494e0b9a08423b65d170bd2235c3b658f7030fd9b9
"0902000100133233313431363030303939333439323932373506f9a9deeaf33bde5646567b129c8da3fee08db6210a8d17f359caf6e3b353bf320100ffffffff01..."

3.9 getrawmempool​

./ela-cli info getrawmempool
[
{
"txid": "acbb3c92e36db7d11e81a16e478943edf5cfb5bc7437e7319d3348fd4c7cb2bf",
"type": 2,
"version": 9,
"vout": [
{
"address": "8PT1XBZboe17rq71Xq1CvMEs8HdKmMztcP",
"value": "10"
}
]
}
]

3.10 listproducers​

Optional flags (when supported by your build): pagination and producer state filter — see ./ela-cli info listproducers -h.

./ela-cli info listproducers
{
"producers": [
{
"active": true,
"index": 0,
"nickname": "PRO-002",
"nodepublickey": "03340dd02ea014133f927ea0828db685e39d9fdc2b9a1b37d2de5b2533d66ef605",
"ownerpublickey": "02690e2887ac7bc2c5d2ffdfeef4d1edc060838fee009c26a18557648f9e6f19a9",
"registerheight": 104,
"state": "Activate",
"url": "https://elastos.net",
"votes": "2"
}
],
"totalcounts": 1,
"totalvotes": "2"
}

4. Mining​

For regtest / private nets and development; not how mainnet consensus is secured.

4.1 Start CPU Mining​

./ela-cli mine -t start
mining started

4.2 Stop CPU Mining​

./ela-cli mine -t stop
mining stopped

4.3 Discrete Mining​

Mine exactly n blocks (useful in controlled environments).

./ela-cli mine -n 1
[e9c1d12d5f4e7679737d1d348e53ce20fc6966e156d0a40d10e3fcf39c94c2f2]

5. Rollback​

Dangerous: truncates local chain data to the given height. Use only when you understand the operational impact (typically private or recovery scenarios).

./ela-cli rollback --height 20
current height is 22
blockhash before rollback: 74858bcb065e89840f27b28a9ff44757eb904f1a7d135206d83b674b9b68fd4e
blockhash after rollback: ...

Resources​