# Mina--CLI参考

By [chezhe](https://paragraph.com/@v2y3x4) · 2021-11-12

---

Mina CLI（命令行界面）是用户与Mina网络互动的主要方式。它提供标准的客户端功能，以创建账户，发送交易，并参与共识。还有一些高级客户端和守护程序命令，供高级用户使用。

CLI是在你[安装Mina](https://docs.minaprotocol.com/en/getting-started#installation)时安装的。

> 警告：Mina的API仍在建设中，所以这些命令可能会改变。请参阅mina帮助以了解最新的版本。

### Mina 账户

    $ mina accounts help
    
    Client commands concerning account management
    
      mina accounts SUBCOMMAND
    
    === subcommands ===
    
      list    List all owned accounts
      create  Create new account
      import  Import a password protected private key to be tracked by the daemon.
              Set CODA_PRIVKEY_PASS environment variable to use non-interactively
              (key will be imported using the same password).
      export  Export a tracked account so that it can be saved or transferred
              between machines.
              Set CODA_PRIVKEY_PASS environment variable to use non-interactively
              (key will be exported using the same password).
      unlock  Unlock a tracked account
      lock    Lock a tracked account
      help    explain a given subcommand (perhaps recursively)
    

### Mina 客户端

    $ mina client help
    
    Lightweight client commands
    
      mina client SUBCOMMAND
    
    === subcommands ===
    
      get-balance           Get balance associated with a public key
      get-tokens            Get all token IDs that a public key has accounts for
      send-payment          Send payment to an address
      delegate-stake        Delegate your stake to another public key
      create-token          Create a new token
      create-token-account  Create a new account for a token
      mint-tokens           Mint more of a token owned by the command's sender
      cancel-transaction    Cancel a transaction -- this submits a replacement
                            transaction with a fee larger than the cancelled
                            transaction.
      set-staking           Start producing blocks
      set-snark-worker      Set key you wish to snark work with or disable snark
                            working
      set-snark-work-fee    Set fee reward for doing transaction snark work
      export-logs           Export daemon logs to tar archive
      export-local-logs     Export local logs (no daemon) to tar archive
      stop-daemon           Stop the daemon
      status                Get running daemon status
      help                  explain a given subcommand (perhaps recursively)
    

### Mina 守护程序

    $ mina daemon -help
    
    Mina daemon
    
      mina daemon
    
    === flags ===
    
      [--all-peers-seen-metric true|false]                whether to track the set
                                                          of all peers ever seen for
                                                          the all_peers metric
                                                          (default: false)
      [--archive-address HOST:PORT/LOCALHOST-PORT]        Daemon to archive process
                                                          communication. If HOST is
                                                          omitted, then localhost is
                                                          assumed to be HOST.
                                                          (examples: 3086,
                                                          154.97.53.97:3086)
      [--archive-rocksdb]                                 Stores all the blocks
                                                          heard in RocksDB
      [--background]                                      Run process on the
                                                          background
      [--bind-ip IP]                                      IP of network interface to
                                                          use for peer connections
      [--block-producer-key KEYFILE]                      Private key file for the
                                                          block producer. You cannot
                                                          provide both
                                                          `block-producer-key` and
                                                          `block-producer-pubkey`.
                                                          (default: don't produce
                                                          blocks)
      [--block-producer-password PASSWORD]                Password associated with
                                                          the block-producer key.
                                                          Setting this is equivalent
                                                          to setting the
                                                          CODA_PRIVKEY_PASS
                                                          environment variable. Be
                                                          careful when setting it in
                                                          the commandline as it will
                                                          likely get tracked in your
                                                          history. Mainly to be used
                                                          from the daemon.json
                                                          config file
      [--block-producer-pubkey PUBLICKEY]                 Public key for the
                                                          associated private key
                                                          that is being tracked by
                                                          this daemon. You cannot
                                                          provide both
                                                          `block-producer-key` and
                                                          `block-producer-pubkey`.
                                                          (default: don't produce
                                                          blocks)
      [--client-port PORT]                                local RPC-server for
                                                          clients to interact with
                                                          the daemon (default: 8301)
      [--coinbase-receiver PUBLICKEY]                     Address to send coinbase
                                                          rewards to (if this node
                                                          is producing blocks). If
                                                          not provided, coinbase
                                                          rewards will be sent to
                                                          the producer of a block.
      [--config-directory DIR]                            Configuration directory
      [--config-file PATH]                                Path to a configuration
                                                          file (overrides
                                                          CODA_CONFIG_FILE, default:
                                                          <config_dir>/daemon.json).
                                                          Pass multiple times to
                                                          override fields from
                                                          earlier config files
      [--current-protocol-version NN.NN.NN]               Current protocol version,
                                                          only blocks with the same
                                                          version accepted
      [--demo-mode]                                       Run the daemon in
                                                          demo-mode -- assume we're
                                                          "synced" to the network
                                                          instantly
      [--direct-peer /ip4/IPADDR/tcp/PORT/p2p/PEERID]     Peers to always send new
                                                          messages to/from. These
                                                          peers should also have you
                                                          configured as a direct
                                                          peer, the relationship is
                                                          intended to be symmetric
      [--disable-node-status]                             Disable reporting node
                                                          status to other nodes
                                                          (default: enabled)
      [--discovery-keypair KEYFILE]                       Keypair (generated from
                                                          `mina advanced
                                                          generate-libp2p-keypair`)
                                                          to use with libp2p
                                                          discovery (default:
                                                          generate per-run temporary
                                                          keypair)
      [--enable-flooding true|false]                      Publish our own
                                                          blocks/transactions to
                                                          every peer we can find
                                                          (default: false)
      [--enable-mina-peer-exchange true|false]            Help keep the mesh
                                                          connected when closing
                                                          connections (default:
                                                          true)
      [--enable-peer-exchange true|false]                 Help keep the mesh
                                                          connected when closing
                                                          connections (default:
                                                          false)
      [--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.
      [--external-port PORT]                              Port to use for all libp2p
                                                          communications (gossip and
                                                          RPC) (default: 8302)
      [--file-log-level LEVEL]                            Set log level for the log
                                                          file
                                                          (Spam|Trace|Debug|Info|Warn|Error|Faulty_peer|Fatal,
                                                          default: Trace)
      [--gc-stat-interval INTERVAL]                       in mins for collecting GC
                                                          stats for metrics
                                                          (Default: 15.000000)
      [--generate-genesis-proof true|false]               Deprecated. Passing this
                                                          flag has no effect
      [--genesis-ledger-dir DIR]                          Directory that contains
                                                          the genesis ledger and the
                                                          genesis blockchain proof
                                                          (default: <config-dir>)
      [--insecure-rest-server]                            Have REST server listen on
                                                          all addresses, not just
                                                          localhost (this is
                                                          INSECURE, make sure your
                                                          firewall is configured
                                                          correctly!)
      [--isolate-network true|false]                      Only allow connections to
                                                          the peers passed on the
                                                          command line or configured
                                                          through GraphQL. (default:
                                                          false)
      [--libp2p-metrics-port PORT]                        libp2p metrics server for
                                                          scraping via Prometheus
                                                          (default no
                                                          libp2p-metrics-server)
      [--limited-graphql-port PORT]                       GraphQL-server for limited
                                                          daemon interaction
      [--log-block-creation true|false]                   Log the steps involved in
                                                          including transactions and
                                                          snark work in a block
                                                          (default: true)
      [--log-json]                                        Print log output as JSON
                                                          (default: plain text)
      [--log-level LEVEL]                                 Set log level
                                                          (Spam|Trace|Debug|Info|Warn|Error|Faulty_peer|Fatal,
                                                          default: Info)
      [--log-precomputed-blocks true|false]               Include precomputed blocks
                                                          in the log (default:
                                                          false)
      [--log-snark-work-gossip true|false]                Log snark-pool diff
                                                          received from peers
                                                          (default: false)
      [--log-txn-pool-gossip true|false]                  Log transaction-pool diff
                                                          received from peers
                                                          (default: false)
      [--max-connections NN]                              max number of connections
                                                          that this peer will have
                                                          to neighbors in the gossip
                                                          network. Tuning this
                                                          higher will strengthen
                                                          your connection to the
                                                          network in exchange for
                                                          using more RAM (default:
                                                          50)
      [--metrics-port PORT]                               metrics server for
                                                          scraping via Prometheus
                                                          (default no
                                                          metrics-server)
      [--minimum-block-reward AMOUNT]                     Minimum reward a block
                                                          produced by the node
                                                          should have. Empty blocks
                                                          are created if the rewards
                                                          are lower than the
                                                          specified threshold
                                                          (default: No threshold,
                                                          transactions and coinbase
                                                          will be included as long
                                                          as the required snark work
                                                          is available and can be
                                                          paid for)
      [--no-super-catchup]                                Don't use super-catchup
      [--open-limited-graphql-port]                       Have the limited GraphQL
                                                          server listen on all
                                                          addresses, not just
                                                          localhost (this is
                                                          INSECURE, make sure your
                                                          firewall is configured
                                                          correctly!)
      [--peer /ip4/IPADDR/tcp/PORT/p2p/PEERID]            initial "bootstrap" peers
                                                          for discovery
      [--peer-list-file /ip4/IPADDR/tcp/PORT/p2p/PEERID]  initial "bootstrap" peers
                                                          for discovery inside a
                                                          file delimited by
                                                          new-lines (\n)
      [--peer-list-url URL]                               URL of seed peer list
                                                          file. Will be polled
                                                          periodically.
      [--precomputed-blocks-file PATH]                    Path to write precomputed
                                                          blocks to, for replay or
                                                          archiving
      [--proof-level]                                     full|check|none
      [--proposed-protocol-version NN.NN.NN]              Proposed protocol version
                                                          to signal other nodes
      [--rest-port PORT]                                  local REST-server for
                                                          daemon interaction
                                                          (default: 3085)
      [--run-snark-coordinator PUBLICKEY]                 Run a SNARK coordinator
                                                          with this public key
                                                          (ignored if the
                                                          run-snark-worker is set)
      [--run-snark-worker PUBLICKEY]                      Run the SNARK worker with
                                                          this public key
      [--seed]                                            Start the node as a seed
                                                          node
      [--snark-worker-fee FEE]                            Amount a worker wants to
                                                          get compensated for
                                                          generating a snark proof
                                                          (default: 100000000)
      [--snark-worker-parallelism NUM]                    Run the SNARK worker using
                                                          this many threads.
                                                          Equivalent to setting
                                                          OMP_NUM_THREADS, but
                                                          doesn't affect block
                                                          production.
      [--stop-time UPTIME]                                in hours after which the
                                                          daemon stops itself (only
                                                          if there were no slots won
                                                          within an hour after the
                                                          stop time) (Default: 24)
      [--tracing]                                         Trace into
                                                          $config-directory/trace/$pid.trace
      [--upload-blocks-to-gcloud true|false]              upload blocks to gcloud
                                                          storage. Requires the
                                                          environment variables
                                                          GCLOUD_KEYFILE,
                                                          NETWORK_NAME, and
                                                          GCLOUD_BLOCK_UPLOAD_BUCKET
      [--uptime-submitter-key KEYFILE]                    Private key file for the
                                                          uptime submitter. You
                                                          cannot provide both
                                                          `uptime-submitter-key` and
                                                          `uptime-submitter-pubkey`.
      [--uptime-submitter-pubkey PUBLICKEY]               Public key of the
                                                          submitter to the Mina
                                                          delegation program, for
                                                          the associated private key
                                                          that is being tracked by
                                                          this daemon. You cannot
                                                          provide both
                                                          `uptime-submitter-key` and
                                                          `uptime-submitter-pubkey`.
      [--uptime-url URL]                                  URL of the uptime service
                                                          of the Mina delegation
                                                          program
      [--validation-queue-size NN]                        size of the validation
                                                          queue in the p2p network
                                                          used to buffer messages
                                                          (like blocks and
                                                          transactions received on
                                                          the gossip network) while
                                                          validation is pending. If
                                                          a transaction, for
                                                          example, is invalid, we
                                                          don't forward the message
                                                          on the gossip net. If this
                                                          queue is too small, we
                                                          will drop messages without
                                                          validating them. If it is
                                                          too large, we are
                                                          susceptible to DoS attacks
                                                          on memory. (default: 150)
      [--work-reassignment-wait WAIT-TIME]                in ms before a snark-work
                                                          is reassigned (default:
                                                          420000ms)
      [--work-selection seq|rand]                         Choose work sequentially
                                                          (seq) or randomly (rand)
                                                          (default: rand)
      [--working-dir PATH]                                path to chdir into before
                                                          starting (useful for
                                                          background mode, defaults
                                                          to cwd, or / if
                                                          -background)
      [-help]                                             print this help text and
                                                          exit
                                                          (alias: -?)
    

### Mina 进阶

    $ mina advanced help
    
    Advanced client commands
    
      mina advanced SUBCOMMAND
    
    === subcommands ===
    
      add-peers                   Add peers to the daemon
                                  Addresses take the format
                                  /ip4/IPADDR/tcp/PORT/p2p/PEERID
      archive-blocks              Archive a block from a file.
                                  If an archive address is given, this process will
                                  communicate with the archive node directly;
                                  otherwise it will communicate through the daemon
                                  over the rest-server
      batch-send-payments         Send multiple payments from a file
      chain-id-inputs             Print the inputs that yield the current chain id
      client-trustlist            Client trustlist management
      compile-time-constants      Print a JSON map of the compile-time consensus
                                  parameters
      compute-receipt-chain-hash  Compute the next receipt chain hash from the
                                  previous hash and transaction ID
      constraint-system-digests   Print MD5 digest of each SNARK constraint
      dump-keypair                Print out a keypair from a private key file
      generate-keypair            Generate a new public, private keypair
      generate-libp2p-keypair     Generate a new libp2p keypair and print out the
                                  peer ID
      get-nonce                   Get the current nonce for an account
      get-peers                   List the peers currently connected to the daemon
      get-public-keys             Get public keys
      get-trust-status            Get the trust status associated with an IP address
      get-trust-status-all        Get trust statuses for all peers known to the
                                  trust system
      hash-transaction            Compute the hash of a transaction from its
                                  transaction ID
      next-available-token        The next token ID that has not been allocated.
                                  Token IDs are allocated sequentially, so all lower
                                  token IDs have been allocated
      node-status                 Get node statuses for a set of peers
      object-lifetime-statistics  Dump internal object lifetime statistics to JSON
      pending-snark-work          List of snark works in JSON format that are not
                                  available in the pool yet
      pooled-user-commands        Retrieve all the user commands that are pending
                                  inclusion
      reset-trust-status          Reset the trust status associated with an IP
                                  address
      send-rosetta-transactions   Dispatch one or more transactions, provided to
                                  stdin in rosetta format
      set-coinbase-receiver       Set the coinbase receiver
      snark-job-list              List of snark jobs in JSON format that are yet to
                                  be included in the blocks
      snark-pool-list             List of snark works in the snark pool in JSON
                                  format
      start-tracing               Start async tracing to
                                  $config-directory/trace/$pid.trace
      status-clear-hist           Clear histograms reported in status
      stop-tracing                Stop async tracing
      time-offset                 Get the time offset in seconds used by the daemon
                                  to convert real time into blockchain time
      validate-keypair            Validate a public, private keypair
      validate-transaction        Validate the signature on one or more
                                  transactions, provided to stdin in rosetta format
      verify-receipt              Verify a receipt of a sent payment
      visualization               Visualize data structures special to Mina
      vrf                         Commands for vrf evaluations
      wrap-key                    Wrap a private key into a private key file
      help                        explain a given subcommand (perhaps recursively)
    

原文：

[https://docs.minaprotocol.com/en/using-mina/cli-reference](https://docs.minaprotocol.com/en/using-mina/cli-reference)

---

*Originally published on [chezhe](https://paragraph.com/@v2y3x4/mina-cli)*
