本文档包含委托人通过命令行界面(CLI)与 Cosmos Hub 交互所需的全部必要信息。 本文档还包含如何管理账户、从 fundraiser 恢复账户以及使用 Ledger Nano 设备的说明。
非常重要:请务必仔细遵循下文所述步骤,因为在这一关键过程中任何疏忽都可能导致你的 Atoms 永久丢失。因此,在继续操作之前,请完整阅读以下说明;如果你需要支持,请联系我们。另请注意,你即将与 Cosmos Hub 交互。它是一项区块链技术,所包含的软件具有很强的实验性质。尽管该区块链已按照当前先进水平进行开发,并经过了极其审慎的审计,我们仍然可能遇到问题、更新和 bug。此外,与区块链技术交互需要较高的技术能力,并且始终伴随着超出我们控制范围的风险。 使用本软件即表示你确认理解与加密软件相关的固有风险(另见 Interchain Cosmos Contribution terms 中的风险章节),并且 Interchain Foundation 和/或 Tendermint Team 不对因使用本软件而产生的潜在损害承担责任。任何基于 Apache 2.0 许可证发布的开源软件的使用,均由你自行承担风险,并按“AS IS”基础提供,不附带任何形式的保证或条件。
请务必格外谨慎。

目录

安装 gaiad

gaiad:这是与 gaiad 全节点交互的命令行界面。
请确认你下载的是当前可用的最新稳定版 gaiad
[下载二进制文件] 暂不可用。 从源码安装
gaiad 需要在终端中使用。打开终端的方法如下:
  • Windows:开始 > 所有程序 > 附件 > 命令提示符
  • MacOS:Finder > Applications > Utilities > Terminal
  • Linux:Ctrl + Alt + T

Cosmos 账户

每个 Cosmos 账户的核心都是一个种子,表现形式为一组由 12 个或 24 个单词组成的助记词。基于这组助记词,可以创建任意数量的 Cosmos 账户,也就是私钥/公钥对。这称为 HD 钱包(有关 HD 钱包规范的更多信息,请参见 BIP32)。
     Account 0                         Account 1                         Account 2

+------------------+              +------------------+               +------------------+
|                  |              |                  |               |                  |
|    Address 0     |              |    Address 1     |               |    Address 2     |
|        ^         |              |        ^         |               |        ^         |
|        |         |              |        |         |               |        |         |
|        |         |              |        |         |               |        |         |
|        |         |              |        |         |               |        |         |
|        +         |              |        +         |               |        +         |
|  Public key 0    |              |  Public key 1    |               |  Public key 2    |
|        ^         |              |        ^         |               |        ^         |
|        |         |              |        |         |               |        |         |
|        |         |              |        |         |               |        |         |
|        |         |              |        |         |               |        |         |
|        +         |              |        +         |               |        +         |
|  Private key 0   |              |  Private key 1   |               |  Private key 2   |
|        ^         |              |        ^         |               |        ^         |
+------------------+              +------------------+               +------------------+
         |                                 |                                  |
         |                                 |                                  |
         |                                 |                                  |
         +--------------------------------------------------------------------+
                                           |
                                           |
                                 +---------+---------+
                                 |                   |
                                 |  Mnemonic (Seed)  |
                                 |                   |
                                 +-------------------+
账户中存储的资金由私钥控制。该私钥通过单向函数由助记词生成。如果你丢失了私钥,可以使用助记词将其找回。但是,如果你丢失了助记词,你将失去对所有派生私钥的访问权限。同样地,如果有人获得了你的助记词,他们也将获得对所有关联账户的访问权限。
不要丢失你的 12 个单词,也不要与任何人分享。为了防止资金被盗或丢失,最佳做法是保留多份助记词副本,并将其存放在安全、可靠的位置,而且只有你自己知道如何访问。如果有人能够获取你的助记词,他们就能够获取你的私钥,并控制与之关联的账户。
地址是带有人类可读前缀的公开字符串(例如 cosmos10snjt8dmpr5my0h76xj48ty80uzwhraqalu4eg),用于标识你的账户。当有人想给你转账时,他们会把资金发送到你的地址。通过地址反推出对应私钥在计算上是不可行的。

从 Fundraiser 恢复账户

注意:本节仅适用于 fundraiser 参与者
如果你参与了 fundraiser,你应该持有一组由 12 个单词组成的助记词。新生成的助记词使用 24 个单词,但 12 个单词的助记词同样兼容所有 Cosmos 工具。

在 Ledger 设备上

Ledger 设备的核心也是一组助记词,用于在多条区块链(包括 Cosmos Hub)上生成账户。通常,你会在初始化 Ledger 设备时创建一组新的助记词。不过,也可以让 Ledger 设备改用用户提供的助记词。下面我们来看看,如何将你在 fundraiser 期间获得的助记词输入为 Ledger 设备的种子。
注意:为执行此操作,最好使用一台全新的 Ledger 设备。 这是因为每台 Ledger 设备只能对应一组助记词。不过,如果你想使用一台已经用种子初始化过的 Ledger,也可以进入 Settings>Device>Reset All 进行重置。请注意,这会清除当前存储在设备上的种子。如果你没有妥善保管关联的助记词,你可能会丢失资金!!!
以下步骤需要在一台尚未初始化的 Ledger 设备上执行:
  1. 通过 USB 将 Ledger 设备连接到计算机
  2. 同时按下两个按钮
  3. 不要选择“Config as a new device”选项,而是选择“Restore Configuration”
  4. 选择一个 PIN 码
  5. 选择 12 个单词选项
  6. 按正确顺序输入你在 fundraiser 期间获得的每个单词。
现在,你的 Ledger 已经使用 fundraiser 助记词正确完成设置。不要丢失这组助记词。如果你的 Ledger 出现问题,你始终可以使用同一组助记词再次恢复到一台新设备上。 接下来,点击这里了解如何生成账户。

在计算机上

注意:在离线计算机上执行此操作会更安全
要使用 fundraiser 助记词恢复账户,并将关联的加密私钥存储到计算机上,请使用以下命令:
gaiad keys add <yourKeyName> --recover
  • <yourKeyName> 是账户名称。它对应于从助记词派生密钥对时使用的账户编号。以后当你想发送交易时,将使用这个名称来标识你的账户。
  • 你可以添加可选的 --account 标志来指定用于生成账户的路径(0、1、2、…)。默认会生成账户 0。
账户 0 的私钥会保存在操作系统的凭据存储中。 每次你想发送交易时,都需要解锁系统的凭据存储。 如果你失去了对凭据存储的访问权限,始终可以使用助记词恢复私钥。
你可能不会在每次发送交易时都被提示输入密码,因为大多数操作系统默认会在用户登录时解锁凭据存储。如果你想修改凭据存储的安全策略,请参阅你的操作系统手册。

创建账户

要创建账户,你只需要先安装好 gaiad。在创建之前,你需要先确定打算将私钥存储在哪里,以及如何与其交互。最佳选择是将私钥存放在专用的离线计算机或 Ledger 设备中。将私钥存储在你日常联网使用的计算机上风险更高,因为任何通过互联网入侵你计算机的人都可能窃取你的私钥并盗走你的资金。

使用 Ledger 设备

仅使用你亲自购买、全新出厂或你完全信任的 Ledger 设备
当你初始化 Ledger 时,设备会生成并存储一组 24 个单词的助记词。该助记词与 Cosmos 兼容,并且可以从中派生出 Cosmos 账户。因此,你只需要让你的 Ledger 与 gaiad 兼容即可。为此,需要完成以下步骤:
  1. 在这里下载 Ledger Live 应用。
  2. 通过 USB 连接你的 Ledger,并更新到最新固件。
  3. 前往 Ledger Live 的应用商店,下载 “Cosmos” 应用(这可能需要一些时间)。注意:你可能需要在 Ledger Live 的 Settings 中启用 Dev Mode,才能下载 “Cosmos” 应用。
  4. 在你的 Ledger 设备上打开 Cosmos 应用。
然后,使用以下命令创建账户:
gaiad keys add <yourAccountName> --ledger
只有在 Ledger 已连接且已解锁时,此命令才会生效
  • <yourKeyName> 是账户名称。它对应于用于从助记词派生密钥对的账户编号。当你要发送交易时,将使用这个名称来标识你的账户。
  • 你可以添加可选的 --account 标志来指定用于生成账户的路径(0、1、2、…)。默认会生成账户 0。

使用电脑

注意:在离线电脑上执行此操作会更安全
要生成账户,只需使用以下命令:
gaiad keys add <yourKeyName>
该命令会生成一组 24 个单词的助记词,并同时保存账户 0 的私钥和公钥。 每次你想发送交易时,都需要解锁系统的凭据存储。 如果你失去了对凭据存储的访问权限, 你始终可以通过助记词恢复私钥。
你在每次发送交易时,可能不一定都会被要求输入密码,因为大多数操作系统默认会在登录时解锁用户的凭据存储。如果你想更改凭据存储的安全策略,请参考你的操作系统手册。
不要丢失你的 12 个单词助记词,也不要与任何人分享。为防止资金被盗或丢失,最佳做法是确保你保留助记词的多份副本,并将其存放在安全、可靠的地方,而且只有你自己知道如何访问。如果有人获得了你的助记词,他们就能获得你的私钥,并控制与之关联的账户。
在你妥善保管好助记词之后(三重确认!),你可以删除 bash 历史记录,以确保没有人能够恢复它:
history -c
rm ~/.bash_history
  • <yourKeyName> 是账户名称。它对应于用于从助记词派生密钥对的账户编号。当你要发送交易时,将使用这个名称来标识你的账户。
  • 你可以添加可选的 --account 标志来指定用于生成账户的路径(0、1、2、…)。默认会生成账户 0。
你可以使用以下命令,通过同一组助记词生成更多账户:
gaiad keys add <yourKeyName> --recover --account 1
该命令会提示你输入密码短语以及助记词。更改账户编号即可生成不同的账户。

访问 Cosmos Hub 网络

为了查询状态并发送交易,你需要一种访问网络的方式。为此,你既可以运行自己的全节点,也可以连接到其他人的节点。
注意:不要与任何人分享你的助记词(12 个或 24 个单词)。唯一应该知道它的人永远只有你自己。尤其是在有人通过电子邮件或私信联系你,要求你为了任何区块链服务或支持而分享助记词时,这一点尤为重要。Cosmos、Tendermint 团队或 Interchain Foundation 都绝不会发送电子邮件,要求你分享任何账户凭据或助记词。。

运行你自己的全节点

这是最安全的选项,但对资源的要求也相对较高。为了运行你自己的全节点,你需要良好的带宽以及至少 1TB 的磁盘空间。 你可以在这里找到如何安装 gaiad 的教程,在这里找到运行全节点的指南。

连接到远程全节点

如果你不想或无法运行自己的节点,也可以连接到其他人的全节点。你应该选择你信任的运营者,因为恶意运营者可能会返回错误的查询结果,或审查你的交易。不过,他们永远无法窃取你的资金,因为你的私钥存储在你本地的电脑或 Ledger 设备中。全节点运营者的可能选项包括验证者、钱包提供商或交易所。 要连接到全节点,你需要一个如下格式的地址:https://77.87.106.33:26657(注意:这只是一个占位符)。这个地址必须由你选择信任的全节点运营者提供。你将在下一节中使用这个地址。

设置 gaiad

在设置 gaiad 之前,请确保你已经设置好了访问 Cosmos Hub 网络的方式
请确认你始终使用的是最新稳定版本的 gaiad
gaiad 是一个工具,使你能够与运行在 Cosmos Hub 网络上的节点交互,无论这个节点是否由你自己运行。下面我们来正确配置它。 要设置 gaiad,请使用以下命令:
gaiad config <flag> <value>
它允许你为每个给定的标志设置默认值。 首先,设置你要连接的全节点地址:
gaiad config node <host>:<port

// example: gaiad config node https://77.87.106.33:26657 (note: this is a placeholder)
如果你运行的是自己的全节点,只需使用 tcp://localhost:26657 作为地址。 最后,设置我们要交互的区块链的 chain-id:
gaiad config chain-id cosmoshub-4

查询状态

在你可以质押 atom 并提取奖励之前,需要先设置 gaiad
gaiad 允许你从区块链中查询所有相关信息,例如账户余额、已绑定代币数量、待领取奖励、治理提案等。下面列出的是委托人最常用的一些命令。
// query account balances and other account-related information
gaiad query account <yourAddress>

// query the list of validators
gaiad query staking validators

// query the information of a validator given their address (e.g. cosmosvaloper1n5pepvmgsfd3p2tqqgvt505jvymmstf6s9gw27)
gaiad query staking validator <validatorAddress>

// query all delegations made from a delegator given their address (e.g. cosmos10snjt8dmpr5my0h76xj48ty80uzwhraqalu4eg)
gaiad query staking delegations <delegatorAddress>

// query a specific delegation made from a delegator (e.g. cosmos10snjt8dmpr5my0h76xj48ty80uzwhraqalu4eg) to a validator (e.g. cosmosvaloper1n5pepvmgsfd3p2tqqgvt505jvymmstf6s9gw27) given their addresses
gaiad query staking delegation <delegatorAddress> <validatorAddress>

// query the rewards of a delegator given a delegator address (e.g. cosmos10snjt8dmpr5my0h76xj48ty80uzwhraqalu4eg)
gaiad query distribution rewards <delegatorAddress>

// query all proposals currently open for depositing
gaiad query gov proposals --status deposit_period

// query all proposals currently open for voting
gaiad query gov proposals --status voting_period

// query a proposal given its proposalID
gaiad query gov proposal <proposalID>
如需更多命令,只需输入:
gaiad query
对于每个命令,你都可以使用 -h 或 --help 标志来获取更多信息。

发送交易

在 Cosmos Hub 主网上,接受的 denom 是 uatom,其中 1atom = 1,000,000uatom

关于 Gas 和手续费的说明

Cosmos Hub 网络上的交易必须包含交易手续费,才能被处理。这笔费用用于支付运行交易所需的 gas。计算公式如下:
fees = ceil(gas * gasPrices)
gas 取决于交易本身。不同的交易需要不同数量的 gas。交易所需的 gas 会在处理过程中计算出来,但你也可以提前通过将 gas 标志设为 auto 来估算。当然,这只是估算值。如果你想确保为交易提供足够的 gas,可以使用 --gas-adjustment 标志(默认值为 1.0)来调整该估算值。在本教程的其余部分中,我们将使用 1.5 的 --gas-adjustment。 gasPrice 是每个 gas 单位的价格。每个验证者都会设置一个 min-gas-price 值,并且只会打包 gasPrice 高于其 min-gas-price 的交易。 交易的 fees 是 gas 和 gasPrice 的乘积。作为用户,你需要在这三个值中输入其中两个。gasPrice/fees 越高,你的交易被打包进区块的概率就越高。
对于主网,推荐的 gas-prices 为 0.0025uatom。

发送代币

在你可以质押 atom 并提取奖励之前,需要先设置 gaiad并创建账户
注意:这些命令需要在联网的电脑上运行。使用 Ledger Nano S 设备执行这些命令会更安全。有关离线流程,请点击这里。
// Send a certain amount of tokens to an address
// Ex value for parameters (do not actually use these values in your tx!!): <to_address>=cosmos16m93fezfiezhvnjajzrfyszml8qm92a0w67ntjhd3d0 <amount>=1000000uatom
// Ex value for flags: <gasPrice>=0.0025uatom

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

质押 ATOM 和提取奖励

在你能够质押 ATOM 和提取奖励之前,你需要先设置 gaiad并创建账户
在质押 ATOM 之前,请先阅读委托人常见问题,以了解委托所涉及的风险和责任
注意:这些命令需要在联网的计算机上运行。使用 Ledger 设备执行这些命令会更安全。离线操作流程请点击这里。
// 向指定验证者质押一定数量的 ATOM
// 标志示例值:<validatorAddress>=cosmosvaloper18thamkhnj9wz8pa4nhnp9rldprgant57pk2m8s, <amountToBound>=10000000uatom, <gasPrice>=0.0025uatom

gaiad tx staking delegate <validatorAddress> <amountToBond> --from <delegatorKeyName> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice>

// 将一定数量的 ATOM 从一个验证者重新委托给另一个验证者
// 仅当你已经委托给某个验证者时才能使用
// 重新委托会立即生效,无需等待期
// 完成一次重新委托后,接下来 3 周内该账户不能再发起其他重新委托
// 标志示例值:<stcValidatorAddress>=cosmosvaloper18thamkhnj9wz8pa4nhnp9rldprgant57pk2m8s, <amountToRedelegate>=100000000uatom, <gasPrice>=0.0025uatom

gaiad tx staking redelegate <srcValidatorAddress> <destValidatorAddress> <amountToRedelegate> --from <delegatorKeyName> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice>

// 提取全部奖励
// 标志示例值:<gasPrice>=0.0025uatom

gaiad tx distribution withdraw-all-rewards --from <delegatorKeyName> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice>

// 从指定验证者处解绑一定数量的 ATOM
// 你需要等待 3 周,ATOM 才会完全解绑并可转账
// 标志示例值:<validatorAddress>=cosmosvaloper18thamkhnj9wz8pa4nhnp9rldprgant57pk2m8s, <amountToUnbound>=10000000uatom, <gasPrice>=0.0025uatom

gaiad tx staking unbond <validatorAddress> <amountToUnbond> --from <delegatorKeyName> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice>
如果你使用已连接的 Ledger,设备会在签名并广播到网络之前要求你确认交易。请注意,只有在 Ledger 已连接且处于解锁状态时,该命令才会生效。
要确认你的交易是否已成功执行,可以使用以下查询:
// 质押 ATOM 或提取奖励后,你的余额应当发生变化
gaiad query account

// 质押 ATOM 后,你应当能看到委托记录
gaiad query staking delegations <delegatorAddress>

// 如果交易已被打包进区块,这里会返回该交易
// 使用你创建交易时显示的交易哈希
gaiad query tx <txHash>

如果你是通过受信任的全节点与网络交互,请再使用区块浏览器核对一次。

参与治理

治理基础概念

Cosmos Hub 内置了一套治理系统,允许已质押的 ATOM 持有者对提案进行投票。提案分为三种类型:
  • Text Proposals:这是最基础的提案类型,可用于征询网络对某个主题的意见。
  • Parameter Proposals:用于更新现有参数的取值。
  • Software Upgrade Proposal:用于提议升级 Hub 的软件。
任何 ATOM 持有者都可以提交提案。要使提案进入可投票状态,必须附带一笔大于 minDeposit 参数的 deposit。这笔 deposit 不必由提交者一次性全部提供。如果初始提案人的 deposit 不足,提案将进入 deposit_period 状态。此时,任何 ATOM 持有者都可以通过发送 depositTx 来增加押金。 当 deposit 达到 minDeposit 后,提案进入 voting_period,持续 2 周。随后,任何已质押的 ATOM 持有者都可以对此提案投票。可选项为 Yes、No、NoWithVeto 和 Abstain。投票权重取决于发送者已质押的 ATOM 数量。如果委托人不投票,则会继承其验证者的投票;不过,委托人也可以自行投票,以覆盖验证者的投票。 在投票期结束时,如果 Yes 票超过 50%(不含 Abstain 票),且 NoWithVeto 票低于 33.33%(不含 Abstain 票),则提案通过。

实际操作

在你能够质押 ATOM 和提取奖励之前,你需要先质押 ATOM
注意:这些命令需要在联网的计算机上运行。使用 Ledger 设备执行这些命令会更安全。离线操作流程请点击这里。
// 提交提案
// <type>=text/parameter_change/software_upgrade
// 标志示例值:<gasPrice>=0.0025uatom

// 提案必须满足最小押金金额,请检查当前链参数
gaiad tx gov submit-legacy-proposal --title "Test Text Proposal" --description "My awesome proposal" --type "text" --deposit=10000000uatom --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice> --from <delegatorKeyName>

// 增加提案押金
// 通过 $gaiad query gov proposals --status deposit_period 获取 proposalID
// 参数示例值:<deposit>=10000000uatom

gaiad tx gov deposit <proposalID> <deposit> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice> --from <delegatorKeyName>

// 对提案投票
// 通过 $gaiad query gov proposals --status voting_period 获取 proposalID
// <option>=yes/no/no_with_veto/abstain

gaiad tx gov vote <proposalID> <option> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice> --from <delegatorKeyName>

在离线计算机上签名交易

如果你没有 Ledger 设备,但希望在离线计算机上使用私钥与网络交互,可以使用以下流程。首先,在联网计算机上使用以下命令生成一笔未签名交易(以下为质押交易示例):
// 质押 ATOM
// 标志示例值:<amountToBound>=10000000uatom, <bech32AddressOfValidator>=cosmosvaloper18thamkhnj9wz8pa4nhnp9rldprgant57pk2m8s, <gasPrice>=0.0025uatom, <delegatorAddress>=cosmos10snjt8dmpr5my0h76xj48ty80uzwhraqalu4eg

gaiad tx staking delegate <validatorAddress> <amountToBond> --from <delegatorAddress> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice> --generate-only > unsignedTX.json
为了签名,你还需要 chain-id、account-number 和 sequence。chain-id 是你提交交易所面向区块链的唯一标识。account-number 是你的账户首次接收资金时生成的标识符。sequence 用于跟踪你发送的交易数量,并防止重放攻击。 从创世文件中获取 chain-id(4),并通过账户查询获取另外两个字段:
gaiad query account <yourAddress> --chain-id cosmoshub-4
然后,复制 unsignedTx.json 并将其传输(例如通过 USB)到离线计算机。如果尚未完成,请先在离线计算机上创建账户。为了进一步提升安全性,你可以在签名前使用以下命令再次检查交易参数:
cat unsignedTx.json
现在,使用以下命令对交易进行签名。你需要填入前面获取到的 chain-id、sequence 和 account-number:
gaiad tx sign unsignedTx.json --from <delegatorKeyName> --offline --chain-id cosmoshub-4 --sequence <sequence> --account-number <account-number> > signedTx.json
复制 signedTx.json 并将其传回联网计算机。最后,使用以下命令广播该交易:
gaiad tx broadcast signedTx.json

This document contains all the necessary information for delegators to interact with the Cosmos Hub through the Command-Line Interface (CLI). It also contains instructions on how to manage accounts, restore accounts from the fundraiser and use a ledger nano device.
Very Important: Please assure that you follow the steps described hereinafter carefully, as negligence in this significant process could lead to an indefinite loss of your Atoms. Therefore, read through the following instructions in their entirety prior to proceeding and reach out to us in case you need support.Please also note that you are about to interact with the Cosmos Hub, a blockchain technology containing highly experimental software. While the blockchain has been developed in accordance to the state of the art and audited with utmost care, we can nevertheless expect to have issues, updates and bugs. Furthermore, interaction with blockchain technology requires advanced technical skills and always entails risks that are outside our control. By using the software, you confirm that you understand the inherent risks associated with cryptographic software (see also risk section of the Interchain Cosmos Contribution terms) and that the Interchain Foundation and/or the Tendermint Team may not be held liable for potential damages arising out of the use of the software. Any use of this open source software released under the Apache 2.0 license is done at your own risk and on a “AS IS” basis, without warranties or conditions of any kind.
Please exercise extreme caution!

Table of Contents

Installing gaiad

gaiad: This is the command-line interface to interact with a gaiad full-node.
Please check that you download the latest stable release of gaiad that is available
[Download the binaries] Not available yet. Install from source
gaiad is used from a terminal. To open the terminal, follow these steps:
  • Windows: Start > All Programs > Accessories > Command Prompt
  • MacOS: Finder > Applications > Utilities > Terminal
  • Linux: Ctrl + Alt + T

Cosmos Accounts

At the core of every Cosmos account, there is a seed, which takes the form of a 12 or 24-words mnemonic. From this mnemonic, it is possible to create any number of Cosmos accounts, i.e. pairs of private key/public key. This is called an HD wallet (see BIP32 for more information on the HD wallet specification).
     Account 0                         Account 1                         Account 2

+------------------+              +------------------+               +------------------+
|                  |              |                  |               |                  |
|    Address 0     |              |    Address 1     |               |    Address 2     |
|        ^         |              |        ^         |               |        ^         |
|        |         |              |        |         |               |        |         |
|        |         |              |        |         |               |        |         |
|        |         |              |        |         |               |        |         |
|        +         |              |        +         |               |        +         |
|  Public key 0    |              |  Public key 1    |               |  Public key 2    |
|        ^         |              |        ^         |               |        ^         |
|        |         |              |        |         |               |        |         |
|        |         |              |        |         |               |        |         |
|        |         |              |        |         |               |        |         |
|        +         |              |        +         |               |        +         |
|  Private key 0   |              |  Private key 1   |               |  Private key 2   |
|        ^         |              |        ^         |               |        ^         |
+------------------+              +------------------+               +------------------+
         |                                 |                                  |
         |                                 |                                  |
         |                                 |                                  |
         +--------------------------------------------------------------------+
                                           |
                                           |
                                 +---------+---------+
                                 |                   |
                                 |  Mnemonic (Seed)  |
                                 |                   |
                                 +-------------------+
The funds stored in an account are controlled by the private key. This private key is generated using a one-way function from the mnemonic. If you lose the private key, you can retrieve it using the mnemonic. However, if you lose the mnemonic, you will lose access to all the derived private keys. Likewise, if someone gains access to your mnemonic, they gain access to all the associated accounts.
Do not lose or share your 12 words with anyone. To prevent theft or loss of funds, it is best to ensure that you keep multiple copies of your mnemonic, and store it in a safe, secure place and that only you know how to access. If someone is able to gain access to your mnemonic, they will be able to gain access to your private keys and control the accounts associated with them.
The address is a public string with a human-readable prefix (e.g. cosmos10snjt8dmpr5my0h76xj48ty80uzwhraqalu4eg) that identifies your account. When someone wants to send you funds, they send it to your address. It is computationally infeasible to find the private key associated with a given address.

Restoring an Account from the Fundraiser

NOTE: This section only concerns fundraiser participants
If you participated in the fundraiser, you should be in possession of a 12-words mnemonic. Newly generated mnemonics use 24 words, but 12-word mnemonics are also compatible with all the Cosmos tools.

On a Ledger Device

At the core of a ledger device, there is a mnemonic used to generate accounts on multiple blockchains (including the Cosmos Hub). Usually, you will create a new mnemonic when you initialize your ledger device. However, it is possible to tell the ledger device to use a mnemonic provided by the user instead. Let us go ahead and see how you can input the mnemonic you obtained during the fundraiser as the seed of your ledger device.
NOTE: To do this, it is preferable to use a brand new ledger device.. Indeed, there can be only one mnemonic per ledger device. If, however, you want to use a ledger that is already initialized with a seed, you can reset it by going in Settings>Device>Reset All. Please note that this will wipe out the seed currently stored on the device. If you have not properly secured the associated mnemonic, you could lose your funds!!!
The following steps need to be performed on an un-initialized ledger device:
  1. Connect your ledger device to the computer via USB
  2. Press both buttons
  3. Do NOT choose the “Config as a new device” option. Instead, choose “Restore Configuration”
  4. Choose a PIN
  5. Choose the 12 words option
  6. Input each of the words you got during the fundraiser, in the correct order.
Your ledger is now correctly set up with your fundraiser mnemonic! Do not lose this mnemonic! If your ledger is compromised, you can always restore a new device again using the same mnemonic. Next, click here to learn how to generate an account.

On a Computer

NOTE: It is more secure to perform this action on an offline computer
To restore an account using a fundraiser mnemonic and store the associated encrypted private key on a computer, use the following command:
gaiad keys add <yourKeyName> --recover
  • <yourKeyName> is the name of the account. It is a reference to the account number used to derive the key pair from the mnemonic. You will use this name to identify your account when you want to send a transaction.
  • You can add the optional --account flag to specify the path (0, 1, 2, …) you want to use to generate your account. By default, account 0 is generated.
The private key of account 0 will be saved in your operating system’s credentials storage. Each time you want to send a transaction, you will need to unlock your system’s credentials store. If you lose access to your credentials storage, you can always recover the private key with the mnemonic.
You may not be prompted for password each time you send a transaction since most operating systems unlock user’s credentials store upon login by default. If you want to change your credentials store security policies please refer to your operating system manual.

Creating an Account

To create an account, you just need to have gaiad installed. Before creating it, you need to know where you intend to store and interact with your private keys. The best options are to store them in an offline dedicated computer or a ledger device. Storing them on your regular online computer involves more risk, since anyone who infiltrates your computer through the internet could exfiltrate your private keys and steal your funds.

Using a Ledger Device

Only use Ledger devices that you bought factory new or trust fully
When you initialize your ledger, a 24-word mnemonic is generated and stored in the device. This mnemonic is compatible with Cosmos and Cosmos accounts can be derived from it. Therefore, all you have to do is make your ledger compatible with gaiad. To do so, you need to go through the following steps:
  1. Download the Ledger Live app here.
  2. Connect your ledger via USB and update to the latest firmware
  3. Go to the ledger live app store, and download the “Cosmos” application (this can take a while). Note: You may have to enable Dev Mode in the Settings of Ledger Live to be able to download the “Cosmos” application.
  4. Navigate to the Cosmos app on your ledger device
Then, to create an account, use the following command:
gaiad keys add <yourAccountName> --ledger
This command will only work while the Ledger is plugged in and unlocked
  • <yourKeyName> is the name of the account. It is a reference to the account number used to derive the key pair from the mnemonic. You will use this name to identify your account when you want to send a transaction.
  • You can add the optional --account flag to specify the path (0, 1, 2, …) you want to use to generate your account. By default, account 0 is generated.

Using a Computer

NOTE: It is more secure to perform this action on an offline computer
To generate an account, just use the following command:
gaiad keys add <yourKeyName>
The command will generate a 24-words mnemonic and save the private and public keys for account 0 at the same time. Each time you want to send a transaction, you will need to unlock your system’s credentials store. If you lose access to your credentials storage, you can always recover the private key with the mnemonic.
You may not be prompted for password each time you send a transaction since most operating systems unlock user’s credentials store upon login by default. If you want to change your credentials store security policies please refer to your operating system manual.
Do not lose or share your 12 words with anyone. To prevent theft or loss of funds, it is best to ensure that you keep multiple copies of your mnemonic, and store it in a safe, secure place and that only you know how to access. If someone is able to gain access to your mnemonic, they will be able to gain access to your private keys and control the accounts associated with them.
After you have secured your mnemonic (triple check!), you can delete bash history to ensure no one can retrieve it:
history -c
rm ~/.bash_history
  • <yourKeyName> is the name of the account. It is a reference to the account number used to derive the key pair from the mnemonic. You will use this name to identify your account when you want to send a transaction.
  • You can add the optional --account flag to specify the path (0, 1, 2, …) you want to use to generate your account. By default, account 0 is generated.
You can generate more accounts from the same mnemonic using the following command:
gaiad keys add <yourKeyName> --recover --account 1
This command will prompt you to input a passphrase as well as your mnemonic. Change the account number to generate a different account.

Accessing the Cosmos Hub Network

In order to query the state and send transactions, you need a way to access the network. To do so, you can either run your own full-node, or connect to someone else’s.
NOTE: Do not share your mnemonic (12 or 24 words) with anyone. The only person who should ever need to know it is you. This is especially important if you are ever approached via email or direct message by someone requesting that you share your mnemonic for any kind of blockchain services or support. No one from Cosmos, the Tendermint team or the Interchain Foundation will ever send an email that asks for you to share any kind of account credentials or your mnemonic.”.

Running Your Own Full-Node

This is the most secure option, but comes with relatively high resource requirements. In order to run your own full-node, you need good bandwidth and at least 1TB of disk space. You will find the tutorial on how to install gaiad here, and the guide to run a full-node here.

Connecting to a Remote Full-Node

If you do not want or cannot run your own node, you can connect to someone else’s full-node. You should pick an operator you trust, because a malicious operator could return incorrect query results or censor your transactions. However, they will never be able to steal your funds, as your private keys are stored locally on your computer or ledger device. Possible options of full-node operators include validators, wallet providers or exchanges. In order to connect to the full-node, you will need an address of the following form: https://77.87.106.33:26657 (Note: This is a placeholder). This address has to be communicated by the full-node operator you choose to trust. You will use this address in the following section.

Setting Up gaiad

Before setting up gaiad, make sure you have set up a way to access the Cosmos Hub network
Please check that you are always using the latest stable release of gaiad
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 set up gaiad, use the following command:
gaiad config <flag> <value>
It allows you to set a default value for each given flag. First, set up the address of the full-node you want to connect to:
gaiad config node <host>:<port

// example: gaiad config node https://77.87.106.33:26657 (note: this is a placeholder)
If you run your own full-node, just use tcp://localhost:26657 as the address. Finally, let us set the chain-id of the blockchain we want to interact with:
gaiad config chain-id cosmoshub-4

Querying the State

Before you can bond atoms and withdraw rewards, you need to set up gaiad
gaiad lets you query all relevant information from the blockchain, like account balances, amount of bonded tokens, outstanding rewards, governance proposals and more. Next is a list of the most useful commands for delegator.
// query account balances and other account-related information
gaiad query account <yourAddress>

// query the list of validators
gaiad query staking validators

// query the information of a validator given their address (e.g. cosmosvaloper1n5pepvmgsfd3p2tqqgvt505jvymmstf6s9gw27)
gaiad query staking validator <validatorAddress>

// query all delegations made from a delegator given their address (e.g. cosmos10snjt8dmpr5my0h76xj48ty80uzwhraqalu4eg)
gaiad query staking delegations <delegatorAddress>

// query a specific delegation made from a delegator (e.g. cosmos10snjt8dmpr5my0h76xj48ty80uzwhraqalu4eg) to a validator (e.g. cosmosvaloper1n5pepvmgsfd3p2tqqgvt505jvymmstf6s9gw27) given their addresses
gaiad query staking delegation <delegatorAddress> <validatorAddress>

// query the rewards of a delegator given a delegator address (e.g. cosmos10snjt8dmpr5my0h76xj48ty80uzwhraqalu4eg)
gaiad query distribution rewards <delegatorAddress>

// query all proposals currently open for depositing
gaiad query gov proposals --status deposit_period

// query all proposals currently open for voting
gaiad query gov proposals --status voting_period

// query a proposal given its proposalID
gaiad query gov proposal <proposalID>
For more commands, just type:
gaiad query
For each command, you can use the -h or --help flag to get more information.

Sending Transactions

On Cosmos Hub mainnet, the accepted denom is uatom, where 1atom = 1,000,000uatom

A Note on Gas and Fees

Transactions on the Cosmos Hub network need to include a transaction fee in order to be processed. This fee pays for the gas required to run the transaction. The formula is the following:
fees = ceil(gas * gasPrices)
The gas is dependent on the transaction. Different transaction require different amount of gas. The gas amount for a transaction is calculated as it is being processed, but there is a way to estimate it beforehand by using the auto value for the gas flag. Of course, this only gives an estimate. You can adjust this estimate with the flag --gas-adjustment (default 1.0) if you want to be sure you provide enough gas for the transaction. For the remainder of this tutorial, we will use a --gas-adjustment of 1.5. The gasPrice is the price of each unit of gas. Each validator sets a min-gas-price value, and will only include transactions that have a gasPrice greater than their min-gas-price. The transaction fees are the product of gas and gasPrice. As a user, you have to input 2 out of 3. The higher the gasPrice/fees, the higher the chance that your transaction will get included in a block.
For mainnet, the recommended gas-prices is 0.0025uatom.

Sending Tokens

Before you can bond atoms and withdraw rewards, you need to set up gaiad and create an account
Note: These commands need to be run on an online computer. It is more secure to perform them commands using a Ledger Nano S device. For the offline procedure, click here.
// Send a certain amount of tokens to an address
// Ex value for parameters (do not actually use these values in your tx!!): <to_address>=cosmos16m93fezfiezhvnjajzrfyszml8qm92a0w67ntjhd3d0 <amount>=1000000uatom
// Ex value for flags: <gasPrice>=0.0025uatom

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

Bonding Atoms and Withdrawing Rewards

Before you can bond atoms and withdraw rewards, you need to set up gaiad and create an account
Before bonding Atoms, please read the delegator faq to understand the risk and responsibilities involved with delegating
Note: These commands need to be run on an online computer. It is more secure to perform them commands using a ledger device. For the offline procedure, click here.
// Bond a certain amount of Atoms to a given validator
// ex value for flags: <validatorAddress>=cosmosvaloper18thamkhnj9wz8pa4nhnp9rldprgant57pk2m8s, <amountToBound>=10000000uatom, <gasPrice>=0.0025uatom

gaiad tx staking delegate <validatorAddress> <amountToBond> --from <delegatorKeyName> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice>

// Redelegate a certain amount of Atoms from a validator to another
// Can only be used if already bonded to a validator
// Redelegation takes effect immediately, there is no waiting period to redelegate
// After a redelegation, no other redelegation can be made from the account for the next 3 weeks
// ex value for flags: <stcValidatorAddress>=cosmosvaloper18thamkhnj9wz8pa4nhnp9rldprgant57pk2m8s, <amountToRedelegate>=100000000uatom, <gasPrice>=0.0025uatom

gaiad tx staking redelegate <srcValidatorAddress> <destValidatorAddress> <amountToRedelegate> --from <delegatorKeyName> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice>

// Withdraw all rewards
// ex value for flag: <gasPrice>=0.0025uatom

gaiad tx distribution withdraw-all-rewards --from <delegatorKeyName> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice>

// Unbond a certain amount of Atoms from a given validator
// You will have to wait 3 weeks before your Atoms are fully unbonded and transferrable
// ex value for flags: <validatorAddress>=cosmosvaloper18thamkhnj9wz8pa4nhnp9rldprgant57pk2m8s, <amountToUnbound>=10000000uatom, <gasPrice>=0.0025uatom

gaiad tx staking unbond <validatorAddress> <amountToUnbond> --from <delegatorKeyName> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice>
If you use a connected Ledger, you will be asked to confirm the transaction on the device before it is signed and broadcast to the network. Note that the command will only work while the Ledger is plugged in and unlocked.
To confirm that your transaction went through, you can use the following queries:
// your balance should change after you bond Atoms or withdraw rewards
gaiad query account

// you should have delegations after you bond Atom
gaiad query staking delegations <delegatorAddress>

// this returns your tx if it has been included
// use the tx hash that was displayed when you created the tx
gaiad query tx <txHash>

Double check with a block explorer if you interact with the network through a trusted full-node.

Participating in Governance

Primer on Governance

The Cosmos Hub has a built-in governance system that lets bonded Atom holders vote on proposals. There are three types of proposal:
  • Text Proposals: These are the most basic type of proposals. They can be used to get the opinion of the network on a given topic.
  • Parameter Proposals: These are used to update the value of an existing parameter.
  • Software Upgrade Proposal: These are used to propose an upgrade of the Hub’s software.
Any Atom holder can submit a proposal. In order for the proposal to be open for voting, it needs to come with a deposit that is greater than a parameter called minDeposit. The deposit need not be provided in its entirety by the submitter. If the initial proposer’s deposit is not sufficient, the proposal enters the deposit_period status. Then, any Atom holder can increase the deposit by sending a depositTx. Once the deposit reaches minDeposit, the proposal enters the voting_period, which lasts 2 weeks. Any bonded Atom holder can then cast a vote on this proposal. The options are Yes, No, NoWithVeto and Abstain. The weight of the vote is based on the amount of bonded Atoms of the sender. If they don’t vote, delegator inherit the vote of their validator. However, delegators can override their validator’s vote by sending a vote themselves. At the end of the voting period, the proposal is accepted if there are more than 50% Yes votes (excluding Abstain votes) and less than 33.33% of NoWithVeto votes (excluding Abstain votes).

In Practice

Before you can bond atoms and withdraw rewards, you need to bond Atoms
Note: These commands need to be run on an online computer. It is more secure to perform them commands using a ledger device. For the offline procedure, click here.
// Submit a Proposal
// <type>=text/parameter_change/software_upgrade
// ex value for flag: <gasPrice>=0.0025uatom

// the proposal must meet the minimum deposit amount - please check the current chain params
gaiad tx gov submit-legacy-proposal --title "Test Text Proposal" --description "My awesome proposal" --type "text" --deposit=10000000uatom --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice> --from <delegatorKeyName>

// Increase deposit of a proposal
// Retrieve proposalID from $gaiad query gov proposals --status deposit_period
// ex value for parameter: <deposit>=10000000uatom

gaiad tx gov deposit <proposalID> <deposit> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice> --from <delegatorKeyName>

// Vote on a proposal
// Retrieve proposalID from $gaiad query gov proposals --status voting_period
// <option>=yes/no/no_with_veto/abstain

gaiad tx gov vote <proposalID> <option> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice> --from <delegatorKeyName>

Signing Transactions From an Offline Computer

If you do not have a ledger device and want to interact with your private key on an offline computer, you can use the following procedure. First, generate an unsigned transaction on an online computer with the following command (example with a bonding transaction):
// Bond Atoms
// ex value for flags: <amountToBound>=10000000uatom, <bech32AddressOfValidator>=cosmosvaloper18thamkhnj9wz8pa4nhnp9rldprgant57pk2m8s, <gasPrice>=0.0025uatom, <delegatorAddress>=cosmos10snjt8dmpr5my0h76xj48ty80uzwhraqalu4eg

gaiad tx staking delegate <validatorAddress> <amountToBond> --from <delegatorAddress> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice> --generate-only > unsignedTX.json
In order to sign, you will also need the chain-id, account-number and sequence. The chain-id is a unique identifier for the blockchain on which you are submitting the transaction. The account-number is an identifier generated when your account first receives funds. The sequence number is used to keep track of the number of transactions you have sent and prevent replay attacks. Get the chain-id from the genesis file (4), and the two other fields using the account query:
gaiad query account <yourAddress> --chain-id cosmoshub-4
Then, copy unsignedTx.json and transfer it (e.g. via USB) to the offline computer. If it is not done already, create an account on the offline computer. For additional security, you can double check the parameters of your transaction before signing it using the following command:
cat unsignedTx.json
Now, sign the transaction using the following command. You will need the chain-id, sequence and account-number obtained earlier:
gaiad tx sign unsignedTx.json --from <delegatorKeyName> --offline --chain-id cosmoshub-4 --sequence <sequence> --account-number <account-number> > signedTx.json
Copy signedTx.json and transfer it back to the online computer. Finally, use the following command to broadcast the transaction:
gaiad tx broadcast signedTx.json