Cli Client

Cli Client

Introduction

stafihubd is a command line client for StaFiHub. StaFiHub users can use stafihubd to send transactions and query the blockchain data.

The default working directory for the stafihubd is $HOME/.stafihub, which is mainly used to save configuration files and data. The StaFiHub key data is saved in the working directory of stafihub. You can also specify the stafihub working directory by --home.

The stafihub node provides a RPC interface, transactions and query requests are sent to the process listening to it. The default rpc address the stafihub is connected to is tcp://localhost:26657, it can also be specified by --node.

Global Flags

GET Commands

All GET commands has the following global flags:

Name,shortlandTypeRequiredDefault ValueDescription
--chain-idstringChain ID of tendermint node
--homestring$HOME/.stafihubDirectory for config and data
--tracestringPrint out full stack trace on errors

POST Commands

All POST commands have the following global flags:

Name,shortlandTypeRequiredDefault ValueDescription
--account-numberint0AccountNumber to sign the tx
--broadcast-modestringsyncTransaction broadcasting mode (sync
--dry-runboolfalseIgnore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fee-accountstringFee account pays fees for the transaction instead of deducting from the signer
--feesstringFees to pay along with transaction
--fromstringName of private key with which to sign
--gasstring200000Gas limit to set per-transaction; set to "simulate" to calculate required gas automatically
--gas-adjustment1Ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--gas-pricesstringGas prices in decimal format to determine the transaction fee
--generate-onlyboolfalseBuild an unsigned transaction and write it to STDOUT
--help, -hstringPrint help message
--keyring-backendstringosSelect keyring's backend
--keyring-dirstringThe client Keyring directory; if omitted, the default 'home' directory will be used
--ledgerboolNote to add a description to the transaction (previously --memo)
--nodestringtcp://localhost:26657: to tendermint rpc interface for this chain
--notestringNote to add a description to the transaction (previously --memo)
--offlinestringfalseOffline mode (does not allow any online functionality)
-o, --outputstringjsonOutput format (text)
--sequenceuint0The sequence number of the signing account (offline mode only)
--sign-modestringChoose sign mode (direct
--timeout-heightboolSet a block timeout height to prevent the tx from being committed past a certain height
--yesbooltrueSkip tx broadcasting prompt confirmation
--chain-idstringChain ID of tendermint node
--homestringDirectory for config and data (default "$HOME/.stafihubd")
--tracestringPrint out full stack trace on errors

Bank

Bank module allows you to manage assets in your local accounts.

Available Commands

NameDescription
balancesQuery for account balances by address
totalQuery the total supply of coins of the chain
sendCreate and/or sign and broadcast a MsgSend transaction

stafihubd query bank balances

stafihubd query bank balances [address] [flags]

Flags:

  • -h, --help: Help for coin-type.
  • --denom: The specific balance denomination to query for.
  • --count-total: Count total number of records in all balances to query for.

stafihubd query bank total

stafihubd query bank total [flags]

Flags:

  • -h, --help: Help for coin-type.
  • --denom: The specific balance denomination to query for.

stafihubd tx bank send

stafihubd tx bank send [from_key_or_address] [to_address] [amount] [flags]

Flags:

  • -h, --help: Help for coin-type.

Debug

A tool for simple debugging.

Available Commands

NameDescription
addrConvert an address between hex and bech32
pubkeyDecode a pubkey from proto JSON
raw-bytesConvert raw bytes output (eg. [10 21 13 127]) to hex

stafihubd debug addr

stafihubd debug addr stafi1m3uxpmweefjdj9kcy3aserws5ggkjsyv50rsh4

returns

Address: [220 120 96 237 217 202 100 217 22 216 36 123 12 141 208 162 17 105 64 140]
Address (hex): DC7860EDD9CA64D916D8247B0C8DD0A21169408C
Bech32 Acc: stafi1m3uxpmweefjdj9kcy3aserws5ggkjsyv50rsh4
Bech32 Val: stafivaloper1m3uxpmweefjdj9kcy3aserws5ggkjsyvv5uecu

stafihubd debug addr

stafihubd debug addr stafi1m3uxpmweefjdj9kcy3aserws5ggkjsyv50rsh4

returns

Address: [220 120 96 237 217 202 100 217 22 216 36 123 12 141 208 162 17 105 64 140]
Address (hex): DC7860EDD9CA64D916D8247B0C8DD0A21169408C
Bech32 Acc: stafi1m3uxpmweefjdj9kcy3aserws5ggkjsyv50rsh4
Bech32 Val: stafivaloper1m3uxpmweefjdj9kcy3aserws5ggkjsyvv5uecu

stafihubd debug addr

stafihubd debug addr stafi1m3uxpmweefjdj9kcy3aserws5ggkjsyv50rsh4

returns

Address: [220 120 96 237 217 202 100 217 22 216 36 123 12 141 208 162 17 105 64 140]
Address (hex): DC7860EDD9CA64D916D8247B0C8DD0A21169408C
Bech32 Acc: stafi1m3uxpmweefjdj9kcy3aserws5ggkjsyv50rsh4
Bech32 Val: stafivaloper1m3uxpmweefjdj9kcy3aserws5ggkjsyvv5uecu

stafihubd debug pubkey

stafihubd debug pubkey '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AurroA7jvfPd1AadmmOvWM2rJSwipXfRf8yD6pLbA2DJ"}'

returns

Address: 620B7D22188F8BDBA267DAF89A857081092A6A6C
PubKey Hex: 02eaeba00ee3bdf3ddd4069d9a63af58cdab252c22a577d17fcc83ea92db0360c9

stafihubd debug raw-bytes

stafihubd debug raw-bytes '[72 101 108 108 111 44 32 112 108 97 121 103 114 111 117 110 100]'

returns

48656C6C6F2C20706C617967726F756E64

Keys

Keys allows you to manage your local tendermint keystore (wallets) for StaFiHub.

Available Commands

NameDescription
addAdd an encrypted private key (either newly generated or recovered), encrypt it, and save to disk
deleteDelete the given key
exportExport private keys
importImport private keys into the local keybase
listList all keys
migrateMigrate keys from the legacy (db-based) Keybase
mnemonicCompute the bip39 mnemonic for some input entropy
parseParse address from hex to bech32 and vice versa
showRetrieve key information by name or address

stafihubd keys add

Derive a new private key and encrypt to disk.

stafihubd keys add <key-name> [flags]

Flags:

  • --multisig: Construct and store a multisig public key.
  • --multisig-threshold: K out of N required signatures.
  • --nosort: Keys passed to --multisig are taken in the order they're supplied.
  • --pubkey: Parse a public key in bech32 format and save it to disk.
  • --interactive: Interactively prompt user for BIP39 passphrase and mnemonic.
  • --ledger: Store a local reference to a private key on a Ledger device.
  • --recover: Provide seed phrase to recover existing key instead of creating.
  • --no-backup: Don't print out seed phrase (if others are watching the terminal) .
  • --dry-run: Perform action, but don't add key to local keystore.
  • --hd-path: Manual HD Path derivation (overrides BIP44 config).
  • --coin-type: coin type number for HD derivation.
  • --account: Account number for HD derivation.
  • --index: Address index number for HD derivation.
  • --algo: Key signing algorithm to generate keys.

Create a new key

stafihubd keys add MyKey

Enter and repeat the password, at least 8 characters, then you will get a new key.

warning: write the seed phrase in a safe place! It is the only way to recover your account if you ever forget your password.

Recover an existing key from seed phrase

If you forget your password or lose your key, or you wanna use your key in another place, you can recover your key by your seed phrase.

stafihubd keys add MyKey --recover

You'll be asked to enter and repeat the new password for your key, and enter the seed phrase. Then you get your key back.

Enter a passphrase for your key:
Repeat the passphrase:
Enter your recovery seed phrase:

Create a multisig key

The following example creates a multisig key with 3 sub-keys, and specify the minimum number of signatures as 2. The tx could be broadcast only when the number of signatures is greater than or equal to 2.

stafihubd keys add <multisig-keyname> --multisig-threshold=2 --multisig=<signer-keyname-1>,<signer-keyname-2>,<signer-keyname-3>

tip <signer-keyname> can be the type oflocal/offline/ledger, but not multi type.

If you don't have all the permission of sub-keys, you can ask for the pubkeys to create the offline keys first, then you will be able to create the multisig key.

Offline key can be created by stafihubd keys add --pubkey.

How to use multisig key to sign and broadcast a transaction, please refer to multisign.

stafihubd keys delete

Delete a local key by the given name.

stafihubd keys delete <key-name> [flags]

Flags:

  • --force, -f: Remove the key unconditionally without asking for the passphrase.
  • --yes, -y: Skip confirmation prompt when deleting offline or ledger key references.

Delete a local key

stafihubd keys delete MyKey

stafihubd keys export

Export the keystore of a key to a json file

stafihubd keys export <key-name> [flags]

Export keystore

stafihubd keys export Mykey --output-file=<path-to-keystore>

stafihubd keys import

stafihubd keys import <name> <keyfile> [flags]

stafihubd keys list

stafihubd keys list

stafihubd keys migrate

stafihubd keys migrate [flags]

stafihubd keys mnemonic

Create a bip39 mnemonic, sometimes called a seed phrase, by reading from the system entropy. To pass your own entropy, use unsafe-entropy mode.

stafihubd keys mnemonic [flags]

Create a bip39 mnemonic

stafihubd keys mnemonic

You'll get a bip39 mnemonic with 24 words, e.g.:

beauty entire blue tape ordinary fix rotate learn smart tiger dolphin cycle cigar dish alcohol slab bachelor vital design consider paper panther mad eternal

stafihubd keys parse

Convert and print to stdout key addresses and fingerprints from hexadecimal into bech32 cosmos prefixed format and vice versa.

Convert and print to stdout key addresses and fingerprints

stafihubd keys parse <hex-or-bech32-address> [flags]

stafihubd keys show

Get details of a local key.

stafihubd keys show <key-name> [flags]

Get details of a local key

stafihubd keys show MyKey

The following infos will be shown:

- name: Mykey
  type: local
  address: iaa1tulwx2hwz4dv8te6cflhda64dn0984harlzegw
  pubkey: iap1addwnpepq24rufap6u0sysqcpgsfzqhw3x8nfkhqhtmpgqt0369rlyqcg0vkgwzc4k0
  mnemonic: ""
  threshold: 0
  pubkeys: []

Get validator operator address

If an address has been bonded to be a validator operator (which the address you used to create a validator), then you can use --bech val to get the operator's address prefixed by iva and the pubkey prefixed by ivp:

stafihubd keys show MyKey --bech val

Example Output:

- name: Mykey
  type: local
  address: iva1tulwx2hwz4dv8te6cflhda64dn0984hakwgk4f
  pubkey: ivp1addwnpepq24rufap6u0sysqcpgsfzqhw3x8nfkhqhtmpgqt0369rlyqcg0vkgd8e6zy
  mnemonic: ""
  threshold: 0
  pubkeys: []

Gov

This module provides the basic functionalities for Governance.

NameDescription
proposalQuery details of a single proposal
proposalsQuery proposals with optional filter
voteQuery details of a single vote
votesQuery votes on a proposal
depositQuery details of a deposit
depositsQuery deposits on a proposal
tallyGet the tally of a proposal vote
paramQuery the parameters (voting)
paramsQuery the parameters of the governance process
proposerQuery which address proposed a proposal with a given ID.
submit-proposalSubmit a proposal along with an initial deposit
voteVote for an active proposal, options: yes/no/no_with_veto/abstain

stafihubd query gov proposal

Query details of a proposal.

stafihubd query gov proposal [proposal-id] [flags]

Query a proposal

stafihubd query gov proposal <proposal-id>

stafihubd query gov proposals

Query proposals with optional filter.

stafihubd query gov proposals [flags]

Query all proposals

stafihubd query gov proposals

Query proposals by conditions

stafihubd query gov proposals --limit=3 --status=Passed --depositor=<iaa...>

stafihubd query gov vote

Query details of a single vote.

stafihubd query gov vote [proposal-id] [voter-addr] [flags]

stafihubd query gov vote

Query details of a single vote.

stafihubd query gov vote [proposal-id] [voter-addr] [flags]

stafihubd query gov deposit

Query details for a single proposal deposit on a proposal by its identifier.

stafihubd query gov deposit [proposal-id] [depositer-addr] [flags]

Query a deposit of a proposal

stafihubd query gov deposit <proposal-id> <iaa...>

Ledger

Ledger module allow users to liquidity stake/unstake rTokens and rToken relayers to send proposals.

Way to Stake/Unstake rToken

  • Stake: Take rATOM as an example, only a common transfer on Cosmos Hub is needed to get rATOM. By sending an amount of ATOM to the given pool accounts of rATOM, rToken relayers will receive the corresponding event and send an execute-bond-proposal to StafiHub which will mint rATOM for the from account.
  • Unstake: liquidity-unbond is the rpc interface for rToken holders to redeem their origin tokens.

Available Query Commands

NameDescription
account-unbondQuery AccountUnbond
bond-recordQuery BondRecord
bond-poolsQuery bonded-pools
chain-eraQuery getChainEra
era-exchange-rateQuery EraExchangeRate by a given denom and era
era-exchange-ratesQuery EraExchangeRatesByDenom
era-unbond-limitQuery getEraUnbondLimit
exchange-rateShow ExchangeRate for a given denom
exchange-rate-listList all ExchangeRate
pool-detailQuery subaccounts and threshold of a pool
pool-unbondQuery unbonds by a given pool
protocol-fee-receiverQuery protocol fee receiver
relay-fee-receiverQuery relay fee receiver
staking-reward-commissionQuery staking reward commission
total-protocol-feeQuery total protocol fee
unbond-commissionQuery getUnbondCommission
unbond-relay-feeQuery getUnbondRelayFee

stafihubd query ledger account-unbond

stafihubd query ledger account-unbond [denom] [unbonder] [flags]

stafihubd query ledger bond-record

stafihubd query ledger bond-record [denom] [txhash] [flags]

stafihubd query ledger bonded-pools

stafihubd query ledger bonded-pools [denom] [flags]

stafihubd query ledger chain-era

stafihubd query ledger chain-era [denom] [flags]

stafihubd query ledger era-exchange-rate

stafihubd query ledger era-exchange-rate [denom] [era] [flags]

stafihubd query ledger era-exchange-rates

stafihubd query ledger era-exchange-rates [denom] [flags]

stafihubd query ledger era-unbond-limit

stafihubd query ledger era-unbond-limit [denom] [flags]

stafihubd query ledger exchange-rate

stafihubd query ledger exchange-rate [denom] [flags]

stafihubd query ledger exchange-rate-list

stafihubd query ledger exchange-rate-list [flags]

stafihubd query ledger pool-detail

stafihubd query ledger pool-detail [denom] [pool] [flags]

stafihubd query ledger pool-unbond

stafihubd query ledger pool-unbond [denom] [pool] [era] [flags]

stafihubd query ledger protocol-fee-receiver

stafihubd query ledger protocol-fee-receiver [flags]

stafihubd query ledger relay-fee-receiver

stafihubd query ledger relay-fee-receiver [denom] [flags]

stafihubd query ledger staking-reward-commission

stafihubd query ledger staking-reward-commission [denom] [flags]

stafihubd query ledger total-protocol-fee

stafihubd query ledger total-protocol-fee [flags]

stafihubd query ledger unbond-commission

stafihubd query ledger unbond-commission [denom] [flags]

stafihubd query ledger unbond-relay-fee

stafihubd query ledger unbond-relay-fee [denom] [flags]

rBank

rBank module allows admin to add new denom and its metadata and address-prefix.

Available Commands

NameDescription
address-prefixQuery address prefix of denom
paramsQuery BondRecord
add-denomAdd metadata and addressPrefix

stafihubd query rbank address-prefix

Query the address-prefix of a specific denomination.

stafihubd query rbank address-prefix [denom] [flags]

stafihubd query rbank params

Query the genesis params of rbank module.

stafihubd query rbank params [flags]

stafihubd tx rbank add-denom

Add a new denom, and its metadata and address-prefix.

stafihubd tx rbank add-denom [address-prefix] [metadata-path] [flags]

Relayers

Relayers module manager kinds of relayers.

Available Commands

NameDescription
relayersQuery relayers
thresholdQuery threshold
add-relayersAdd new relayers
delete-relayersDelete a relayer
set-thresholdSet threshold

stafihubd query relayers relayers

Query the relayers of a specific denomination and arena.

stafihubd query relayers relayers [arena] [denom] [flags]

stafihubd query relayers threshold

Query the threshold of a specific denomination and arena.

stafihubd query relayers threshold [arena] [denom] [flags]

stafihubd tx relayers add-relayers

Add relayers for a specific denomination and arena.

stafihubd tx relayers add-relayers [arena] [denom] [addresses] [flags]

stafihubd tx relayers delete-relayer

Delete a relayer for a specific denomination and arena.

stafihubd tx relayers delete-relayer [arena] [denom] [address] [flags]

stafihubd tx relayers set-threshold

Set the threshold for a specific denomination and arena, the default value is 0 if unset.

stafihubd tx relayers set-threshold [arena] [denom] [value] [flags]

rVote

Available Commands

NameDescription
proposalQuery Proposal
proposal-lifeQuery ProposalLife
set-proposal-lifeSet ProposalLife

stafihubd query rvote proposal

Query the proposal of a specific prop-id.

stafihubd query rvote proposal [prop-id] [flags]

stafihubd query rvote proposal-life

Query ProposalLife, ProposalLife indicates how long a proposal can be voted on.

stafihubd query rvote proposal-life [flags]

stafihubd tx rvote set-proposal-life

Add a new denom, and its metadata and address-prefix.

stafihubd tx rvote set-proposal-life [proposal-life] [flags]

staking

Staking module provides a set of subcommands to query staking state and send staking transactions.

Available Commands

NameDescription
validatorQuery a validator
validatorsQuery for all validators
delegationsQuery a delegation based on address and validator address
delegations-toQuery all delegations to one validator
unbonding-delegationQuery an unbonding-delegation record based on delegator and validator address
unbonding-delegationsQuery all unbonding-delegations records for one delegator
unbonding-delegations-from
redelegation-fromQuery all outgoing redelegatations from a validator
redelegationQuery a redelegation record based on delegator and a source and destination validator address
redelegationsQuery all redelegations records for one delegator
poolQuery the current staking pool values
paramsQuery the current staking parameters information
historical-infoQuery historical info at given height
create-validatorCreate new validator initialized with a self-delegation to it
edit-validatorEdit existing validator account
delegateDelegate liquid tokens to an validator
unbondUnbond shares from a validator
redelegateRedelegate illiquid tokens from one validator to another

stafihubd query staking validator

Query a validator by validator address

stafihubd query staking validator <iva...>

stafihubd query staking validators

Query all validators

stafihubd query staking validators

stafihubd query staking delegation

Query a delegation based on delegator address and validator address.

stafihubd query staking delegation [delegator-addr] [validator-addr]

Query a delegation

stafihubd query staking delegation <iaa...> <iva...>

Example Output:

Delegation:
  Delegator:  iaa13lcwnxpyn2ea3skzmek64vvnp97jsk8qrcezvm
  Validator:  iva15grv3xg3ekxh9xrf79zd0w077krgv5xfzzunhs
  Shares:     1.0000000000000000000000000000
  Height:     26

stafihubd query staking delegations

Query all delegations delegated from one delegator.

stafihubd query staking delegations [delegator-address] [flags]

Query all delegations of a delegator

stafihubd query staking delegations <iaa...>

stafihubd query staking delegations-to

Query all delegations to one validator.

stafihubd query staking delegations-to [validator-address] [flags]

Query all delegations to one validator

stafihubd query staking delegations-to <iva...>

Example Output:

Delegation:
  Delegator:  iaa13lcwnxpyn2ea3skzmek64vvnp97jsk8qrcezvm
  Validator:  iva1yclscskdtqu9rgufgws293wxp3njsesxxlnhmh
  Shares:     100.0000000000000000000000000000
  Height:     0
Delegation:
  Delegator:  iaa1td4xnefkthfs6jg469x33shzf578fed6n7k7ua
  Validator:  iva1yclscskdtqu9rgufgws293wxp3njsesxxlnhmh
  Shares:     1.0000000000000000000000000000
  Height:     26

stafihubd query staking unbonding-delegation

Query an unbonding-delegation record based on delegator and validator address.

stafihubd query staking unbonding-delegation [delegator-addr] [validator-addr] [flags]

Query an unbonding delegation record

stafihubd query staking unbonding-delegation <iaa...> <iva...>

stafihubd query staking unbonding-delegations

Query all unbonding delegations records of a delegator

stafihubd query staking unbonding-delegations <iaa...>

stafihubd query staking unbonding-delegations-from

Query all unbonding delegations from a validator

stafihubd query staking unbonding-delegations-from <iva...>

stafihubd query staking redelegations-from

Query all outgoing redelegations of a validator

stafihubd query staking redelegations-from [validator-address] [flags]

Query all outgoing redelegatations of a validator

stafihubd query staking redelegations-from <iva...>

stafihubd query staking redelegation

Query a redelegation record based on delegator and source validator address and destination validator address.

stafihubd query staking redelegation [delegator-addr] [src-validator-addr] [dst-validator-addr] [flags]

Query a redelegation record

stafihubd query staking redelegation <iaa...> <iva...> <iva...>

stafihubd query staking redelegations

Query all redelegations records of a delegator

stafihubd query staking redelegations <iaa...>

stafihubd query staking pool

Query the current staking pool values

stafihubd query staking pool

Example Output:

Pool:
  Loose Tokens:   1409493892.759816067399143966
  Bonded Tokens:  590526409.65743521209068061
  Token Supply:   2000020302.417251279489824576
  Bonded Ratio:   0.2952602076

stafihubd query staking params

Query the current staking parameters information

stafihubd query staking params

stafihubd query staking historical-info

Query historical info at given height

stafihubd query staking historical-info <height>

stafihubd tx staking create-validator

Send a transaction to apply to be a validator and delegate a certain amount of fis to it.

stafihubd tx staking create-validator [flags]

Create a validator

stafihubd tx staking create-validator --chain-id=stafihub --from=<key-name> --fees=0.3fis --pubkey=<validator-pubKey> --commission-rate=0.1 --amount=100fis --moniker=<validator-name>

stafihubd tx staking edit-validator

Edit an existing validator's settings, such as commission rate, name, etc.

stafihubd tx staking edit-validator [flags]

Flags:

  • --amount: Required, amount of coins to bond.
  • --commission-rate: Required, the initial commission rate percentage.
  • --commission-max-rate: The maximum commission rate percentage.
  • --commission-max-change-rate: The maximum commission change rate percentage (per day).
  • --min-self-delegation: The minimum self delegation required on the validator.
  • --details: Optional details.
  • --genesis-format: Export the transaction in gen-tx format; it implies --generate-only.
  • --identity: Optional identity signature (ex. UPort or Keybase).
  • --ip: Node's public IP. It takes effect only when used in combination with.
  • --node-id: The node's ID.
  • --moniker: Validator name.
  • --pubkey: Go-Amino encoded hex PubKey of the validator. For Ed25519 the go-amino prepend hex is 1624de6220.
  • --website: Optional website.
  • --security-contact: The validator's (optional) security contact email.

Edit validator information

stafihubd tx staking edit-validator --from=<key-name> --chain-id=stafihub --fees=0.3fis --commission-rate=0.10 --moniker=<validator-name>

Upload validator avatar

Please refer to How to upload my validator's logo to the Explorers

stafihubd tx staking delegate

Delegate tokens to a validator.

stafihubd tx staking delegate [validator-addr] [amount] [flags]
stafihubd tx staking delegate <iva...> <amount> --chain-id=stafihub --from=<key-name> --fees=0.3fis

stafihubd tx staking unbond

Unbond tokens from a validator.

stafihubd tx staking unbond [validator-addr] [amount] [flags]

Unbond some tokens from a validator

stafihubd tx staking unbond <iva...> 10fis --from=<key-name> --chain-id=stafihub --fees=0.3fis

stafihubd tx staking redelegate

Transfer delegation from one validator to another.

tips: There is no unbonding time during the redelegation, so you will not miss the rewards. But you can only redelegate once per validator, until a period (= unbonding time) exceed.

stafihubd tx staking redelegate [src-validator-addr] [dst-validator-addr] [amount] [flags]

Redelegate some tokens to another validator

stafihubd tx staking redelegate <iva...> <iva...> 10fis --chain-id=stafihub --from=<key-name> --fees=0.3fis