本指南将说明如何安装 gaiad 二进制文件并运行 CLI。将该二进制文件安装到服务器后,你可以作为 全节点 或 验证者 参与主网。

构建要求

目前,SDK 已完整支持在 Linux 发行版上安装。为便于说明,本文将使用 Ubuntu 22.04 LTS。你也可以在 Unix 系统上安装 gaiad,而 Windows 可能需要额外的、未受支持的第三方安装方式。下面列出了全新安装所需的全部步骤。
  1. 更新并安装构建工具
  2. 安装 Go
  3. 安装 Gaiad 二进制文件

构建工具

安装 make 和 gcc。 Ubuntu:
sudo apt update

sudo apt install -y make gcc build-essential

安装 Go

需要 Go 1.23+。
我们建议使用以下两种方式之一安装 Go。请查看官方文档和 Go 安装程序,以获取适合你操作系统的正确下载项。或者,你也可以通过命令行自行安装 Go。下文列出了标准的默认安装位置,但你也可以按需自定义。 自 Gaia v18 引入 CosmWasm 以来,建议在启用 CGO 的情况下构建二进制文件,只需在构建前于终端中设置 CGO_ENABLED=1。 由于依赖问题,Windows 上不支持构建 gaiad 二进制文件。 Go 二进制下载 Ubuntu: 在撰写本文时,最新版本为 1.23.6。我们将下载 tarball,将其解压到 /usr/local,并把 GOROOT 导出到 $PATH 中。
curl -OL https://go.dev/dl/go1.23.6.darwin-amd64.tar.gz

sudo tar -C /usr/local -xvf go1.23.6.darwin-amd64.tar.gz

export PATH=$PATH:/usr/local/go/bin

请记得将 GOPATH 添加到你的 $PATH 环境变量中。如果你不确定它在哪里,请运行 go env GOPATH。这样我们就能在下一步运行 gaiad 二进制文件。如果你不确定如何设置 $PATH,请参考这些说明。
export PATH=$PATH:$(go env GOPATH)/bin

安装二进制文件

接下来,我们来安装最新版 Gaia。请确保你已 git checkout 到正确的发布版本。
git clone -b <latest-release-tag> https://github.com/cosmos/gaia.git
cd gaia && make install
如果该命令因以下错误信息失败,你可能是在执行此步骤之前已经设置了 LDFLAGS。
flag provided but not defined: -L
usage: link [options] main.o
...
make: *** [install] Error 2
取消设置这个环境变量后再试一次。
LDFLAGS="" make install
注意:如果你在这一步仍然遇到问题,请检查是否安装了最新稳定版的 GO。
这将安装 gaiad 二进制文件。运行以下命令以验证是否安装成功:
gaiad version --long
你应该会看到类似如下的输出:
name: gaia
server_name: gaiad
version: v18.0.0
commit: 682770f2410ab0d33ac7f0c7203519d7a99fa2b6
build_tags: netgo,ledger,muslc
go: go version go1.23.6 linux/amd64

Docker

在 gaia 仓库中提供了 Dockerfile。 构建方式:
git clone -b <latest-release-tag> https://github.com/cosmos/gaia.git
cd gaia
docker build -t cosmos-ics:local -f Dockerfile ./

静态链接

如果你需要构建一个将所有依赖都静态链接的二进制文件,请查看我们的 Dockerfile。 你的机器上必须提供 libwasmvm。 请选择与你的平台和操作系统匹配的构建版本: 更多信息请查看 wasmvm 的文档。

构建标签

构建标签表示该二进制文件启用了哪些特殊特性。
构建标签说明
netgo名称解析将使用纯 Go 代码
ledger支持 Ledger 设备(硬件钱包)
static_wasm/muslc用于静态链接的 wasmd 依赖

配合 Cosmos SDK 克隆仓库使用

如果你想基于自己修改过的 Cosmos SDK 进行开发,请先 fork 此仓库,然后在 go.mod 文件中添加 replace 子句。 你添加到 go.mod 中的 replace 子句必须提供正确的导入路径。
go mod edit -replace github.com/cosmos/cosmos-sdk=../cosmos-sdk
go mod tidy
make install # or make build

下一步

现在你可以加入主网或加入公共测试网。
This guide will explain how to install the gaiad binary and run the cli. With this binary installed on a server, you can participate on the mainnet as either a Full Node or a Validator.

Build Requirements

At present, the SDK fully supports installation on linux distributions. For the purpose of this instruction set, we’ll be using Ubuntu 22.04 LTS. It is also possible to install gaiad on Unix, while Windows may require additional unsupported third party installation. All steps are listed below for a clean install.
  1. Update & install build tools
  2. Install Go
  3. Install Gaiad binaries

Build Tools

Install make and gcc. Ubuntu:
sudo apt update

sudo apt install -y make gcc build-essential

Install Go

Go 1.23+ is required.
We suggest the following two ways to install Go. Check out the official docs and Go installer for the correct download for your operating system. Alternatively, you can install Go yourself from the command line. Detailed below are standard default installation locations, but feel free to customize. Since the introduction of CosmWasm in Gaia v18 it is recommended to build the binaries with CGO enabled - simply set CGO_ENABLED=1 in your terminal before building the binary. Building the gaiad binary on Windows is not supported due to dependency issues. Go Binary Downloads Ubuntu: At the time of this writing, the latest release is 1.23.6. We’re going to download the tarball, extract it to /usr/local, and export GOROOT to our $PATH
curl -OL https://go.dev/dl/go1.23.6.darwin-amd64.tar.gz

sudo tar -C /usr/local -xvf go1.23.6.darwin-amd64.tar.gz

export PATH=$PATH:/usr/local/go/bin

Remember to add GOPATH to your $PATH environment variable. If you’re not sure where that is, run go env GOPATH. This will allow us to run the gaiad binary in the next step. If you’re not sure how to set your $PATH take a look at these instructions.
export PATH=$PATH:$(go env GOPATH)/bin

Install the binaries

Next, let’s install the latest version of Gaia. Make sure you git checkout the correct released version.
git clone -b <latest-release-tag> https://github.com/cosmos/gaia.git
cd gaia && make install
If this command fails due to the following error message, you might have already set LDFLAGS prior to running this step.
flag provided but not defined: -L
usage: link [options] main.o
...
make: *** [install] Error 2
Unset this environment variable and try again.
LDFLAGS="" make install
NOTE: If you still have issues at this step, please check that you have the latest stable version of GO installed.
That will install the gaiad binary. Verify that everything installed successfully by running:
gaiad version --long
You should see something similar to the following:
name: gaia
server_name: gaiad
version: v18.0.0
commit: 682770f2410ab0d33ac7f0c7203519d7a99fa2b6
build_tags: netgo,ledger,muslc
go: go version go1.23.6 linux/amd64

Docker

Dockerfile is available in the gaia repo. Building:
git clone -b <latest-release-tag> https://github.com/cosmos/gaia.git
cd gaia
docker build -t cosmos-ics:local -f Dockerfile ./

Static linking

In case you need to build a binary with all dependencies statically linked please check our Dockerfile. You must have libwasmvm available on your machine. Choose the build that matches your platform and OS: For more information, please check wasmvm documentation.

Build Tags

Build tags indicate special features that have been enabled in the binary.
Build TagDescription
netgoName resolution will use pure Go code
ledgerLedger devices are supported (hardware wallets)
static_wasm/muslcUsed for statically linked wasmd dependencies

Work with a Cosmos SDK Clone

To work with your own modifications of the Cosmos SDK, make a fork of this repo, and add a replace clause to the go.mod file. The replace clause you add to go.mod must provide the correct import path.
go mod edit -replace github.com/cosmos/cosmos-sdk=../cosmos-sdk
go mod tidy
make install # or make build

Next

Now you can join the mainnet, the public testnet.