简介

Cosmos SDK 运行区块链节点需要 Go 环境以及构建好的二进制文件。本教程将介绍如何安装 Go、构建 simd 二进制文件,并配置环境以运行 Cosmos SDK 节点。

前置条件

本教程假设你已经安装了以下工具:
  • 终端应用程序
  • 代码编辑器
  • 对命令行操作有基本了解

1. 安装 Go

Cosmos SDK 要求 Go 版本为 1.25 或更高。请从Go 官方下载页面下载安装程序,并按照你的操作系统对应的安装说明完成安装。 验证安装:
go version

配置 Go 环境变量

打开你的 shell 配置文件(~/.bashrc 或 ~/.zshrc),并添加:
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
应用更改:source ~/.bashrc
验证:go env GOPATH

2. 克隆 Cosmos SDK 仓库

本教程使用 simapp,即 Cosmos SDK 的示例应用。克隆 Cosmos SDK 仓库以获取 simapp。
  1. 进入你希望使用的目录。此示例使用 ~/Documents/GitHub:
cd ~/Documents/GitHub
  1. 克隆 Cosmos SDK 仓库:
git clone https://github.com/cosmos/cosmos-sdk.git
  1. 进入克隆后的仓库目录:
cd cosmos-sdk
如果你正在构建自己的链,请改为克隆你自己的链仓库。并在本教程中将 simd 替换为你链对应的二进制名称。

3. 构建 simd 二进制文件

simd 二进制文件是用于与 Cosmos SDK 区块链交互的命令行接口。 构建并安装 simd 二进制文件:
make install
Windows 用户:如果系统中没有 make,你可以通过 Chocolatey 安装(choco install make),或者使用 WSL2。
验证 simd 是否可用:
simd version
现在你的环境已经配置完成,可以运行 Cosmos SDK 节点。

后续步骤


Introduction

The Cosmos SDK requires Go and a built binary to run a blockchain node. This tutorial walks through installing Go, building the simd binary, and configuring your environment to run a Cosmos SDK node.

Prerequisites

This tutorial assumes you have the following installed:
  • A terminal application
  • A code editor
  • Basic familiarity with command-line operations

1. Install Go

The Cosmos SDK requires Go version 1.25 or higher. Download the installer from the official Go downloads page and follow the installation instructions for your operating system. Verify the installation:
go version

Configure Go environment variables

Open your shell config file (~/.bashrc or ~/.zshrc) and add:
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
Apply changes: source ~/.bashrc
Verify: go env GOPATH

2. Clone the Cosmos SDK repository

This tutorial uses simapp, the Cosmos SDK example application. Clone the Cosmos SDK repository to access simapp.
  1. Navigate to your preferred directory. This example uses ~/Documents/GitHub:
cd ~/Documents/GitHub
  1. Clone the Cosmos SDK repository:
git clone https://github.com/cosmos/cosmos-sdk.git
  1. Navigate into the cloned repository:
cd cosmos-sdk
If you are building your own chain, clone your chain’s repository instead. Replace simd with your chain’s binary name throughout this tutorial.

3. Build the simd binary

The simd binary is the command-line interface for interacting with the Cosmos SDK blockchain. Build and install the simd binary:
make install
Windows users: If make is not available, you can install it via Chocolatey (choco install make) or use WSL2.
Verify simd is working:
simd version
Your environment is now set up to run a Cosmos SDK node.

Next steps