CLI Commands

From Mina Wiki
Revision as of 13:08, 28 September 2020 by Dan (talk | contribs) (Text replacement - "CODA" to "MINA")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

When managing a Mina node, these CLI (command line interface) commands can help you stay on top of your node's status.

Add these helpful commands to your $HOME/.bashrc configuration file so that you can run them just by remembering a simple alias.


Keep track of how much work your SNARK worker has retrieved and how much it has completed:

alias minawork="echo -e \"Work Received: $(grep 'Get_work' ~/.mina-config/mina.log | wc -l)\nWork Completed: $(grep 'completed work' ~/.mina-config/mina.log | wc -l)\""

Node from scratch script

Update and get latest Mina version

   sudo apt-get remove mina-testnet-postake-medium-curves
   sudo apt-get remove mina-kademlia
   echo "deb [trusted=yes] release main" | sudo tee /etc/apt/sources.list.d/mina.list
   sudo apt-get update
   sudo apt-get install -t release mina-testnet-postake-medium-curves make jq -y 

Copy Mina keys

  tar zcvf keys.tar.gz
  chmod -R 700 keys
  echo "export MINA_PK=\"$(cat keys/\"" >> ~/.bashrc

Run Mina

   mina daemon -external-port 8302 -discovery-port 8303 \
     -peer /dns4/ \
     -peer /dns4/ \
     -propose-key ~/keys/my-wallet > log.txt

In another console...

  mina client status

Utility Commands

Import keys:

mina advanced import -privkey-path <keypath>

Unlock keys:

mina accounts unlock -public-key <public key>

Check if your node is banned:

mina advanced get-trust-status -ip-address <ip address>

Next Proposal:

mina client status -json | jq .next_proposal[1]

Check balance:

mina client get-balance -public-key <public key>

Full list

Required arguments are denoted inside < and > Optional arguments are inside [ and ]. Usage: mina [command] [subcommand] [flags]

Command Subcommand Flags Description
accounts list [-rest-port PORT] [-rest-port PORT] [-help] List all owned accounts
create [-rest-port PORT] [-rest-port PORT] [-help] Create new account
import <-privkey-path FILE> [-config-directory DIR] [-rest-port PORT] [-rest-port PORT] [-help] Import a password protected private key to be tracked by the daemon.
unlock <-public-key KEY> [-rest-port PORT] [-rest-port PORT] [-help] Unlock a tracked account
lock <-public-key KEY> [-rest-port PORT] [-rest-port PORT] [-help] Lock a tracked account
help [-expand-dots] [-flags] [-recursive] [-help] explain a given subcommand (perhaps recursively)
daemon [-archive] Archive all blocks heard
[-background] Run process on the background
[-bind-ip IP] Configuration directory
[-config-directory DIR] Unlock a tracked account
[-disable-libp2p-discovery] Disable libp2p discovery
[-discovery-keypair PUBKEY,PRIVKEY,PEERID] Keypair (generated from `mina advanced generate-libp2p-keypair`) to use with libp2p discovery (default: generate new temporary keypair)
[-discovery-port PORT] Port to use for peer-to-peer discovery (default: 28675)
[-enable-old-discovery] Enable the old Haskell Kademlia discovery
[-external-ip IP] External IP address for other nodes to connect to. You only need to set this if auto-discovery fails for some reason.
[-insecure-rest-server] Have REST server listen on all addresses, not just localhost (this is INSECURE, make sure your firewall is configured correctly!)
[-kademlia-peer HOST:PORT] TCP daemon communications (can be given multiple times)
false] Limit the number of concurrent connections per IP address (default: true)
[-log-json] Print daemon log output as JSON (default: plain text)
[-log-level Set] daemon log level (default: Info)
false] Log blocks received from peers (default:false)
false] Log snark-pool diff received from peers (default:false)
false] Log snark-pool diff received from peers (default:false)
[-metrics-port PORT] metrics server for scraping via Prometheus (default no metrics-server)
[-peer /ip4/IPADDR/tcp/PORT/ipfs/PEERID] initial "bootstrap" peers for libp2p discovery
[-propose-key KEYFILE] Private key file for the block producer. You cannot provide both `propose-key` and `propose-public-key`. (default: don't produce blocks)
[-rest-port PORT] local REST-server for daemon interaction (default: 3085)
[-run-snark-worker PUBLICKEY] local REST-server for daemon public key
[-snark-worker-fee FEE] Amount a worker wants to get compensated for generating a snark proof (default: 1)
[-tracing] Trace into $config-directory/$pid.trace
[-work-reassignment-wait WAIT-TIME] in ms before a snark-work is reassigned (default: 420000ms)
rand] Choose work sequentially (seq) or randomly (rand) (default: rand)
[-help] print this help text and exit (alias: -?)
client get-balance <-public-key KEY> [-rest-port PORT] [-rest-port PORT] [-help] Get balance associated with a public key
send-payment <-amount VALUE> <-receiver PUBLICKEY> >-sender KEY> [-fee FEE] [-memo STRING] [-nonce NONCE] [-rest-port PORT] [-rest-port PORT] [-help] Send payment to an address
delegate-stake <-receiver PUBLICKEY> <-sender KEY> [-fee FEE] [-memo STRING] [-nonce NONCE] [-rest-port PORT] [-rest-port PORT] [-help] Delegate your stake to another public key
cancel-transaction <-id ID> [-rest-port PORT] [-help] Cancel a transaction -- this submits a replacement transaction with a fee larger than the cancelled transaction.
set-staking <-public-key PUBLICKEY> [-rest-port PORT] [-help] Start producing blocks
set-snark-worker [-address PUBLICKEY] [-rest-port PORT] [-help] Set key you wish to snark work with or disable snark working
set-snark-work-fee [-rest-port PORT] [-help] Set fee reward for doing transaction snark work
stop-daemon [-rest-port PORT] [-help] Stop the daemon
status [-daemon-port PORT] [-json] [-performance] [-help] Get running daemon status
help [-expand-dots] [-flags] [-recursive] [-help] explain a given subcommand (perhaps recursively)
advanced batch-send-payments PAYMENT-FILE <-privkey-path FILE> [-daemon-port PORT] [-help] Send multiple payments from a file
constraint-system-digests [-help] Print MD5 digest of each SNARK constraint
dump-keypair <-privkey-path FILE> [-help] Print out a keypair from a private key file
dump-ledger [-daemon-port PORT] [-json] [-staged-ledger-hash (default: hash of best staged ledger) STAGED-LEDGER-HASH] [-help] Print the ledger with given Merkle root
generate-libp2p-keypair [-help] Generate a new libp2p keypair and print it out (this contains the secret key!)
get-nonce <-address PUBLICKEY> [-daemon-port PORT] [-help] Get the current nonce for an account
get-public-keys [-daemon-port PORT] [-json] [-with-details] [-help] Get public keys
get-trust-status <-ip-address IP> [-daemon-port PORT] [-json] [-help] Get trust statuses for all peers known to the trust system
import <-privkey-path FILE> [-config-directory DIR] [-rest-port PORT] [-help] Import a password protected private key to be tracked by the daemon
pending-snark-work [-rest-port PORT] [-help] List of snark works in JSON format that are not available in the pool yet
pooled-user-commands [-rest-port PORT] [-help] Retrieve all the user commands submitted by the current daemon that are pending inclusion
reset-trust-status <-ip-address IP> [-daemon-port PORT] [-json] [-help] Reset the trust status associated with an IP address
snark-job-list [-daemon-port PORT] [-help] List of snark jobs in JSON format that are yet to be included in the blocks
snark-pool-list [-rest-port PORT] [-help] ist of snark works in the snark pool in JSON forman
start-tracing [-daemon-port PORT] [-help] Start async tracing to $config-directory/$pid.trace
status-clear-hist [-daemon-port PORT] [-json] [-performance] [-help] Clear histograms reported in status
stop-tracing [-daemon-port PORT] [-help] Stop async tracing
unsafe-import <-privkey-path FILE> [-config-directory DIR] [-help] Unsafely import a password protected private key to one with the password stripped, but tracked by this daemon and accessible via the GraphQL API
visualization <registered-masks OUTPUT-FILEPATH> OR < transition-frontier OUTPUT-FILEPATH> [-daemon-port PORT] [-help] Visualize data structures special to Mina
wrap-key <-privkey-path FILE> [-help] Wrap a private key into a private key file
help [-expand-dots] [-flags] [-recursive] [-help] explain a given subcommand (perhaps recursively)
internal run-prover [-help] Run prover on a sexp provided on a single line of stdin
snark-hashes [-json] [-help] List hashes of proving and verification keys
snark-worker false] [-help] Print out a keypair from a private key file
help [-expand-dots] [-flags] [-recursive] [-help] explain a given subcommand (perhaps recursively)
parallel-worker [NAME] [-help] internal use only
snark-flame-graphs [-help] transaction snark profiler
snark-flame-graphs [-check-only] Just check base snarks, don't keys or time anything
[-k count] count = log_2(number of transactions to snark) or none for the mocked ones
[-preeval true/false] whether to pre-evaluate the checked computation to cache interpreter and computation state
[-repeat count] number of times to repeat the profile
[-witness-only] Just generate the witnesses for the base snarks
[-help] print this help text and exit (alias: -?)
version [-help] print version information
help [subcommand] [-expand-dots] [-flags] [-recursive] [-help] explain a given subcommand (perhaps recursively)