Skip to content

Wallet command line interface

Rodney Lorrimar edited this page Oct 31, 2019 · 62 revisions

The CLI is a proxy to the wallet server, which is required for most commands. Commands are turned into corresponding API calls, and submitted to an up-and-running server. Some commands do not require an active server and can be run "offline". (e.g. 'mnemonic generate')

Usage: cardano-wallet COMMAND
  Cardano Wallet Command-Line Interface (CLI)

Available OPTIONS:
  -h | --help

Available COMMANDS:
  launch              Launch and monitor a wallet server and its chain producers.
  serve               Serve an HTTP API that listens for commands/actions.
  mnemonic                            
    generate          Generate BIP-39 mnemonic words
  wallet
    list              List all known wallets
    create            Create & restore a wallet from a BIP-39 mnemonic sentence
    get               Fetch a particular wallet
    utxo              Get a wallet's UTxO distribution 
    update
      passphrase      Update a wallet's master passphrase
      name            Update a wallet's name 
    delete            Forget a wallet and its metadata
  transaction
    create            Create a transaction from a known wallet
    fees              Estimate fees for a transaction
    list              List the transactions associated with a wallet
    submit            Submit an externally-signed transaction
    forget            Forget a pending transaction with specified id
  address
    list              List all known addresses of a wallet
  stake-pool
      list            List all known stake pools
  network
    information       View network information
  version             Show the program's current version

ℹ️ The CLI commands for wallet, transaction and address only output valid JSON on stdout. So you may redirect the output to a file with > or pipe it into utility softwares like jq!

💝 For bash/zsh auto-completion, put the following script in your /etc/bash_completion.d:

cardano-wallet.sh
_cardano-wallet()
{
   local CMDLINE
   local IFS=$'\n'
   CMDLINE=(--bash-completion-index $COMP_CWORD)

   for arg in ${COMP_WORDS[@]}; do
       CMDLINE=(${CMDLINE[@]} --bash-completion-word $arg)
   done

   COMPREPLY=( $(cardano-wallet "${CMDLINE[@]}") )
}

complete -o filenames -F _cardano-wallet cardano-wallet

Commands

launch

Launches and manages two sub-processes:

  • A wallet server (using cardano-wallet serve)
  • A target chain producer (Jörmungandr)

This is a shortcut command for those looking into an out-of-the-box solution for running the software.

Many options supported by cardano-wallet serve are also supported by launch.

Invocation

cardano-wallet launch 
  [--listen-address HOST] ([--random-port] | [--port INT])
  [--node-port INT]
  [--state-dir DIR]
  [--logging-config FILE.YAML] ([--quiet] | [--verbose])
  (--genesis-block-hash STRING | --genesis-block FILE) 
  [-- ARGUMENTS...]
--state-dir

cardano-wallet launch will store the wallet databases and Jörmungandr chain data inside the folder specified by --state-dir. If it does not exist, it will be created.

--genesis-block | --genesis-block-hash

The genesis block file can be obtained using Jörmungandr's tool command-line jcli as follows:

$ jcli genesis encode --input genesis.yaml > block0.bin

Here below is an example of genesis file that can be used for testing:

genesis.yaml
# The Blockchain Configuration defines the different settings
# of the blockchain that cannot be changed once the blockchain
# is started.
blockchain_configuration:
  # The block0-date defines the date the blockchain starts
  # expected value in seconds since UNIX_EPOCH
  block0_date: 1556202057

  # This is the type of dicrimination of the blockchain
  # of this blockchain is meant for production then
  # use 'production' instead.
  #
  # otherwise leave as this
  discrimination: test

  # The initial consensus version:
  #
  # * BFT consensus: bft
  # * Genesis Praos consensus: genesis
  block0_consensus: genesis_praos

  # Number of slots in each epoch
  slots_per_epoch: 500

  # The slot duration, in seconds, is the time between the creation
  # of 2 blocks
  slot_duration: 10

  # The number of blocks (*10) per epoch
  epoch_stability_depth: 10

  # A list of Ed25519 Extended PublicKey that represents the
  # BFT leaders encoded as bech32. The order in the list matters.
  consensus_leader_ids:
    - ed25519_pk1haythczarvl75wt6y6fmq0gjz7j9xcyfatwchj523wdawechkd8qp735w5

  # Genesis praos parameter D
  bft_slots_ratio: 0

  # Genesis praos active slot coefficient
  # Determines minimum stake required to try becoming slot leader, must be in range (0,1]
  consensus_genesis_praos_active_slot_coeff: 0.22

  # This is the max number of messages allowed in a given Block
  max_number_of_transactions_per_block: 255

  # The fee calculations settings
  #
  # fee(num_bytes, has_certificate) = constant + num_bytes * coefficient + has_certificate * certificate
  linear_fees:
    constant: 42
    coefficient: 0
    certificate: 0

  # The speed to update the KES Key in seconds
  kes_update_speed: 43200 # 12hours

# The initial deposits present in the blockchain.
initial:
  - fund:
      address: ta1swk7svu8avn5jysl83vja72lp0sqfczanqee6q08a4j7q27a77kpg4p254a
      value: 100000000000
  # And so forth... 
example
$ cardano-wallet launch --genesis-block block0.bin -- --secret secret.yaml
-- ARGUMENTS...

All other arguments are passed to the jormungandr child process. Place -- before the Jörmungandr arguments so that they are not interpreted as cardano-wallet arguments.

top ⤴️

serve

Serve API that listens for commands/actions. Before launching user should start jormungandr (see details on the provided link).

Invocation

cardano-wallet serve
  [--listen-address HOST] ([--random-port] | [--port INT])
  [--node-port INT]
  [--database DIR]
  [--logging-config FILE.YAML] ([--quiet] | [--verbose])
  --genesis-block-hash STRING
--listen-address

Which hostname or IP address to bind the API server to.

As an example, to bind to the IPv4 local host only, use 127.0.0.1. This is the default listen address.

The --listen-address option recognizes the following special values:

Special Value Meaning
* any IPv4 or IPv6 hostname
*4 any IPv4 or IPv6 hostname, IPv4 preferred
!4 any IPv4 hostname
*6 any IPv4 or IPv6 hostname, IPv6 preferred
!6 any IPv6 hostname

Note that the permissive * values allow binding to an IPv4 or an IPv6 hostname, which means you might be able to successfully bind to a port more times than you expect (e.g. once on the IPv4 localhost 127.0.0.1 and again on the IPv6 localhost 0:0:0:0:0:0:0:1).

If using the special syntax, remember to 'quote' or backslash-escape the value so that your shell does not interpret them as glob patterns.

--database

Wallet databases will be stored in this directory. If it does not exist it will be created. The database files are in SQLite format, and there will be at least one database file per wallet.

--logging-config

Use a YAML configuration file for fine-grained control over logging.

See iohk-monitoring-framework/iohk-monitoring/test/config.yaml for an example.

--genesis-block-hash

This is a hash of the the genesis block file which can obtained using Jörmungandr's tool command-line jcli as follows:

$ jcli genesis hash --input block0.bin

See also launch via Jörmungandr for details about how to generate block0.bin.

example

Start Jörmungandr:

$ jormungandr --genesis-block block0.bin --config config.yaml --secret secret.yaml

Then, start the wallet backend server:

$ cardano-wallet serve --genesis-block-hash $(jcli genesis hash --input block0.bin)

top ⤴️

mnemonic generate

cardano-wallet mnemonic generate [--size=INT]

Generates mnemonic words

$ cardano-wallet mnemonic generate

These words will be used to create a wallet later. You may also ask for a specific number of words using the --size option:

$ cardano-wallet mnemonic generate --size 21

top ⤴️

wallet list

cardano-wallet wallet list [--port=INT]

Lists all your wallets:

$ cardano-wallet wallet list

top ⤴️

wallet create

cardano-wallet wallet create [--port=INT] <name> [--address-pool-gap=INT]

Create a new wallet using a sequential address scheme. This is an interactive command that will prompt you for mnemonic words and password.

$ cardano-wallet wallet create "My Wallet"
Please enter a 15–24 word mnemonic sentence: <enter generated mnemonic words here>
(Enter a blank line if you do not wish to use a second factor.)
Please enter a 9–12 word mnemonic second factor: <skip or enter new mnemonic words here>
Please enter a passphrase: ****************
Enter the passphrase a second time: ****************

after this your new wallet will be created

top ⤴️

wallet get

cardano-wallet wallet get [--port=INT] WALLET_ID

Fetches the wallet with specified wallet id:

$ cardano-wallet wallet get 2512a00e9653fe49a44a5886202e24d77eeb998f

top ⤴️

wallet utxo

cardano-wallet wallet utxo [--port=INT] WALLET_ID

Visualize a wallet's UTxO distribution in the form of an histrogram with a logarithmic scale. The distribution's data is returned by the API in a JSON format, e.g.:

{
  "distribution": {
      "10": 1,
      "100": 0,
      "1000": 8,
      "10000": 14,
      "100000": 32,
      "1000000": 3,
      "10000000": 0,
      "100000000": 12,
      "1000000000": 0,
      "10000000000": 0,
      "100000000000": 0,
      "1000000000000": 0,
      "10000000000000": 0,
      "100000000000000": 0,
      "1000000000000000": 0,
      "10000000000000000": 0,
      "45000000000000000": 0
  }
}

which could be plotted as:

    │
100 ─
    │
    │                                 ┌───┐
 10 ─                         ┌───┐   │   │                   ┌───┐
    │                 ┌───┐   │   │   │   │                   │   │
    │                 │   │   │   │   │   │   ┌───┐           │   │
  1 ─ ┌───┐           │   │   │   │   │   │   │   │           │   │
    │ │   │           │   │   │   │   │   │   │   │           │   │
    │ │   │ │       │ │   │ │ │   │ ╷ │   │ ╷ │   │ ╷       ╷ │   │      ╷ 
    └─┘   └─│───────│─┘   └─│─┘   └─│─┘   └─│─┘   └─│───────│─┘   └──────│────────────
          10μ₳    100μ₳   1000μ₳   0.1₳    1₳      10₳     100₳        1000₳

top ⤴️

wallet update name

cardano-wallet wallet update name [--port=INT] WALLET_ID STRING

Updates name of a wallet given wallet id:

$ cardano-wallet wallet update name 2512a00e9653fe49a44a5886202e24d77eeb998f NewName

top ⤴️

wallet update passphrase

cardano-wallet wallet update passphrase [--port=INT] WALLET_ID

Interactive prompt to update the wallet master's passphrase (old passphrase required).

$ cardano-wallet wallet update passphrase 2512a00e9653fe49a44a5886202e24d77eeb998f
Please enter your current passphrase: **********
Please enter a new passphrase: **********
Enter the passphrase a second time: **********

top ⤴️

wallet delete

cardano-wallet wallet delete [--port=INT] WALLET_ID

Deletes wallet with specified wallet id:

$ cardano-wallet wallet delete 2512a00e9653fe49a44a5886202e24d77eeb998f

top ⤴️

transaction create

cardano-wallet transaction create [--port=INT] WALLET_ID --payment=PAYMENT...

Creates and submits a new transaction:

$ cardano-wallet transaction create 2512a00e9653fe49a44a5886202e24d77eeb998f \
    --payment [email protected] \
    --payment [email protected]

This creates a transaction that sends 22 lovelace to Ae2tdPwUPEZ...nRtbfw6EHRv1D and 5 lovelace to Ae2tdPwUPEZ7...pVwEPhKwseVvf from wallet with id 2512a00e9653fe49a44a5886202e24d77eeb998f.

top ⤴️

transaction fees

cardano-wallet transaction fees [--port=INT] WALLET_ID --payment=PAYMENT...

Estimates fee for a given transaction:

$ cardano-wallet transaction fees 2512a00e9653fe49a44a5886202e24d77eeb998f \
    --payment [email protected] \
    --payment [email protected]

This estimates fees for a transaction that sends 22 lovelace to Ae2tdPwUPEZ...nRtbfw6EHRv1D and 5 lovelace to Ae2tdPwUPEZ7...pVwEPhKwseVvf from wallet with id 2512a00e9653fe49a44a5886202e24d77eeb998f.

top ⤴️

transaction list

cardano-wallet transaction list [--port INT] WALLET_ID [--start TIME] [--end TIME] [--order ORDER]

List all incoming and outgoing transactions for the wallet:

$ cardano-wallet transaction list 2512a00e9653fe49a44a5886202e24d77eeb998f \
    --start 2018-09-25T10:15:00Z \
    --end 2019-11-21T10:15:00Z \
    --order ascending

This lists all transactions between 2018-09-25T10:15:00Z and 2019-11-21T10:15:00Z in ascending order.

top ⤴️

transaction submit

cardano-wallet transaction submit [--port INT] BINARY_BLOB

Submit transaction prepared and signed outside of the wallet:

$ cardano-wallet transaction submit 00bf02010200000...d21942304

Sends transaction identified by a hex-encoded BINARY_BLOB of externally-signed transaction.

top ⤴️

transaction forget

cardano-wallet transaction forget [--port INT] WALLET_ID TRANSACTION_ID

Forget pending transaction for a given wallet:

$ cardano-wallet transaction forget 2512a00e9653fe49a44a5886202e24d77eeb998f 3e6ec12da4414aa0781ff8afa9717ae53ee8cb4aa55d622f65bc62619a4f7b12

top ⤴️

address list

cardano-wallet address list [--port=INT] WALLET_ID [--state=STRING]

List all known (used or not) addresses and their corresponding status.

$ cardano-wallet list addresses 2512a00e9653fe49a44a5886202e24d77eeb998f

top ⤴️

stake pool list

cardano-wallet stake-pool list [--port=INT]

List all known stake pools with some statistics about them.

$ cardano-wallet stake-pools list

top ⤴️

network information

cardano-wallet network information [--port=INT]

View network information and syncing progress between the node and the blockchain.

version

cardano-wallet version

Show the software version.

top ⤴️

Clone this wiki locally