Gaia Daemon
gaiad is the tool that enables you to interact with the node that runs on the Cosmos Hub network, whether you run it yourself or not. Let us set it up properly. In order to install it, follow the installation procedure.
Setting up gaiad
The main command used to set upgaiad is the following:
tcp://localhost:26657 as the address.
Finally, let us set the chain-id of the blockchain we want to interact with:
Keys
Keyring
The keyring holds the private/public keypairs used to interact with a node. For instance, a validator key needs to be set up before running the blockchain node, so that blocks can be correctly signed. The private key can be stored in different locations, called “backends”, such as a file or the operating system’s own key storage. Headless environments are recommended to use either thefile or pass backends. More information is available at the SDK documentation page.
Key Types
There are three types of key representations that are used:-
cosmos- Derived from account keys generated by
gaiad keys add - Used to receive funds
- e.g.
cosmos15h6vd5f0wqps26zjlwrc6chah08ryu4hzzdwhc
- Derived from account keys generated by
-
cosmosvaloper- Used to associate a validator to its operator
- Used to invoke staking commands
- e.g.
cosmosvaloper1carzvgq3e6y3z5kz5y6gxp3wpy3qdrv928vyah
-
cosmospub- Derived from account keys generated by
gaiad keys add - e.g.
cosmospub1zcjduc3q7fu03jnlu2xpl75s2nkt7krm6grh4cc5aqth73v0zwmea25wj2hsqhlqzm
- Derived from account keys generated by
-
cosmosvalconspub- Generated when the node is created with
gaiad init. - Get this value with
gaiad tendermint show-validator - e.g.
cosmosvalconspub1zcjduepq0ms2738680y72v44tfyqm3c9ppduku8fs6sr73fx7m666sjztznqzp2emf
- Generated when the node is created with
Migrate Keys From Legacy On-Disk Keybase To OS Built-in Secret Store
Older versions ofgaiad used store keys in the user’s home directory. If you are migrating
from an old version of gaiad you will need to migrate your old keys into your operating system’s
credentials storage by running the following command:
Generate Keys
You’ll need an account private and public key pair (a.k.a.sk, pk respectively) to be able to receive funds, send txs, bond tx, etc.
To generate a new secp256k1 key:
<account_name>:
Generate Multisig Public Keys
You can generate and print a multisig public key by typing:K is the minimum number of private keys that must have signed the
transactions that carry the public key’s address as signer.
The --multisig flag must contain the name of public keys that will be combined into a
public key that will be generated and stored as new_key_name in the local database.
All names supplied through --multisig must already exist in the local database. Unless
the flag --nosort is set, the order in which the keys are supplied on the command line
does not matter, i.e. the following commands generate two identical keys:
Tx Broadcasting
When broadcasting transactions,gaiad accepts a --broadcast-mode flag. This
flag can have a value of sync (default), async, or block, where sync makes
the client return a CheckTx response, async makes the client return immediately,
and block makes the client wait for the tx to be committed (or timing out).
It is important to note that the block mode should not be used in most
circumstances. This is because broadcasting can timeout but the tx may still be
included in a block. This can result in many undesirable situations. Therefore, it
is best to use sync or async and query by tx hash to determine when the tx
is included in a block.
Fees & Gas
The Cosmos Hub uses thex/feemarket module to
dynamically vary the gas price based on demand.
You need to specify a sufficient gas price or total fees
to ensure that your transaction is included in a block,
e.g.
Account
Get Tokens
On a testnet, getting tokens is usually done via a faucet.Query Account Balance
After receiving tokens to your address, you can view your account’s balance by typing:Note
When you query an account balance with zero tokens, you will get this error:
No account with address <account_cosmos> was found in the state. This can also happen if you fund the account before your node has fully synced with the chain. These are both normal.Send Tokens
The following command could be used to send coins from one account to another:amount argument accepts the format value|coin_name.
You may want to cap the maximum gas that can be consumed by the transaction via the
--gas flag.
If you pass --gas=auto, the gas supply will be automatically estimated before executing the transaction.
Gas estimate might be inaccurate as state changes could occur in between the end of the simulation and the actual execution of a transaction, thus an adjustment is applied on top of the original estimate in order to ensure the transaction is broadcasted successfully. The adjustment can be controlled via the --gas-adjustment flag, whose default value is 1.0.--block flag:
--dry-run flag to the command line:
--generate-only to the list of the command line arguments:
The
--generate-only flag prevents gaiad from accessing the local keybase.
Thus when such flag is supplied sender_key_name_or_address must be an address.Query Transactions
Matching a Set of Events
You can use the transaction search command to query for transactions that match a specific set ofevents, which are added on every transaction.
Each event is composed by a key-value pair in the form of {eventType}.{eventAttribute}={value}.
Events can also be combined to query for a more specific result using the & symbol.
You can query transactions by events as follows:
events:
page and limit:
Type() function of the relevant message.
You can find a list of available events on each of the SDK modules:
Matching a Transaction’s Hash
You can also query a single transaction by its hash using the following command:Slashing
Unjailing
To unjail your jailed validatorSigning Info
To retrieve a validator’s signing info:Query Parameters
You can get the current slashing parameters via:Minting
You can query for the minting/inflation parameters via:Staking
Set up a Validator
Please refer to the Validator Setup section for a more complete guide on how to set up a validator-candidate.Delegate to a Validator
On the upcoming mainnet, you can delegateatom to a validator. These delegators can receive part of the validator’s fee revenue. Read more about the Cosmos Token Model.
Query Validators
You can query the list of all validators of a specific chain:Bond Tokens
On the Cosmos Hub mainnet, we delegateuatom, where 1atom = 1000000uatom. Here’s how you can bond tokens to a testnet validator (i.e. delegate):
<validator> is the operator address of the validator to which you intend to delegate. If you are running a local testnet, you can find this with:
[name] is the name of the key you specified when you initialized gaiad.
While tokens are bonded, they are pooled with all the other bonded tokens in the network. Validators and delegators obtain a percentage of shares that equal their stake in this pool.
Query Delegations
Once submitted a delegation to a validator, you can see its information by using the following command:Unbond Tokens
If for any reason the validator misbehaves, or you just want to unbond a certain amount of tokens, use the following command.Query Unbonding-Delegations
Once you begin an unbonding-delegation, you can see it’s information by using the following command:Redelegate Tokens
A redelegation is a type delegation that allows you to bond illiquid tokens from one validator to another:shares-amount or a shares-fraction with the corresponding flags.
The redelegation will be automatically completed when the unbonding period has passed.
Query Redelegations
Once you begin a redelegation, you can see its information by using the following command:Query Parameters
Parameters define high level settings for staking. You can get the current values by using:- Unbonding time
- Maximum numbers of validators
- Coin denomination for staking
governance process by ParameterChange proposals.
Query Pool
A stakingPool defines the dynamic parameters of the current state. You can query them with the following command:
pool command you will get the values for:
- Not-bonded and bonded tokens
- Token supply
- Current annual inflation and the block in which the last inflation was processed
- Last recorded bonded shares
Query Delegations To Validator
You can also query all of the delegations to a particular validator:Governance
Governance is the process from which users in the Cosmos Hub can come to consensus on software upgrades, parameters of the mainnet or signaling mechanisms through text proposals. This is done through voting on proposals, which will be submitted byATOM holders on the mainnet.
Some considerations about the voting process:
- Voting is done by bonded
ATOMholders on a 1 bondedATOM1 vote basis - Delegators inherit the vote of their validator if they don’t vote
- Votes are tallied at the end of the voting period (2 weeks on mainnet) where
each address can vote multiple times to update its
Optionvalue (paying the transaction fee each time), only the most recently cast vote will count as valid - Voters can choose between options
Yes,No,NoWithVetoandAbstain - At the end of the voting period, a proposal is accepted iff:
(YesVotes / (YesVotes+NoVotes+NoWithVetoVotes)) > 1/2(NoWithVetoVotes / (YesVotes+NoVotes+NoWithVetoVotes)) < 1/3((YesVotes+NoVotes+NoWithVetoVotes) / totalBondedStake) >= quorum
Create a Governance Proposal
In order to create a governance proposal, you must submit an initial deposit along with a title and description. Various modules outside of governance may implement their own proposal types and handlers (eg. parameter changes), where the governance module itself supportsText proposals. Any module
outside of governance has its command mounted on top of submit-proposal.
To submit a Text proposal:
--proposal flag which
points to a JSON file containing the proposal.
To submit a parameter change proposal, you must provide a proposal file as its
contents are less friendly to CLI input:
proposal.json contains the following:
The
SoftwareUpgrade is currently not supported as it’s not implemented and currently does not differ from the semantics of a Text proposal.Query Proposals
Once created, you can now query information of the proposal:voter or depositor by using the corresponding flags.
To query for the proposer of a given governance proposal:
Increase Deposit
In order for a proposal to be broadcasted to the network, the amount deposited must be above aminDeposit value (initial value: 512000000uatom). If the proposal you previously created didn’t meet this requirement, you can still increase the total amount deposited to activate it. Once the minimum deposit is reached, the proposal enters voting period:
MaxDepositPeriod is reached.
Query Deposits
Once a new proposal is created, you can query all the deposits submitted to it:Vote on a Proposal
After a proposal’s deposit reaches theMinDeposit value, the voting period opens. Bonded Atom holders can then cast vote on it:
Query Votes
Check the vote with the option you just submitted:Query proposal tally results
To check the current tally of a given proposal you can use thetally command: