# Gnoland智能合约平台测试任务教程

By [arden](https://paragraph.com/@aptosui) · 2022-08-27

---

Gno项目简介
-------

[Gnoland](https://gno.land)是Cosmos前创始人[Jae Kwon](https://twitter.com/jaekwon)创立的可互操作的高并发智能合约平台，开发者可以用Gno语言在Gno链上构建高并发智能合约，Gno语言是类似于Go语言的智能合约开发语言，语法简单，凭借大量的Go开发人员，相对Solidity、Rust、Move等语言大大降低了开发者的入门门槛，目前Gnoland还处于Test2测试网阶段，周边配套工具还很欠缺，使用门槛比较高，需要一定的技术能力才能率先体验，也正是因为这一点目前体验的人还比较少，不卷，自然大家的机会也会比较大。

### 基础环境安装

本系列教程的操作系统环境为基于ubuntu，大家也可以使用Windows的[WSL版Ubuntu](https://docs.microsoft.com/zh-cn/windows/wsl/install)在自己的电脑上部署。

首先大家在服务器上的 / 目录下创建一个新的目录 /data 用于存放平时所需要软件操作的统一目录，主要是方便后续对服务器资源进行统一管理，主要是不同的软件都会有自己默认的安装目录，如果不统一管理，后面软件安装多了就容易乱套。

    sudo apt-get update -y && sudo apt-get upgrade -y
    sudo apt-get install curl build-essential jq git -y
    
    cd /
    
    mkdir data
    
    cd /data
    
    mkdir app software soft source blockchain
    

目录说明

/data/app 主要存放安装软件（主要以软件链接的方式连接到 /data/soft 目录下的软件）

/data/software 主要存放从网上下载的软件

/data/soft 主要存放安装软件（软件安装的真目录）

/data/source 主要存放从Github上clone下来的源代码

/data/blockchain 主要存放区块链相关工具服务

当然目录结构大家可以根据自己的喜好自己定义。

### Go开发环境安装

    cd /data/software
    wget https://go.dev/dl/go1.18.5.linux-amd64.tar.gz
    tar -xzvf go1.18.5.linux-amd64.tar.gz
    tar -xzvf go1.18.5.linux-amd64.tar.gz -C/data/soft
    cd /data/soft
    mv go go1.18.5
    ln -s /data/soft/go1.18.5 /data/app/go
    
    cat << 'EOF' >> /etc/profile
    export PATH=$PATH:/data/app/go/bin
    EOF
    
    source /etc/profile
    
    go version
    

### 下载安装Gno源代码并编译

    cd /data/source
    git clone https://github.com/gnolang/gno
    cd gno
    make
    
    # 如果编译的时候下载安装包时网络超时出错，则配置一个Goproxy代理，具体使用如下命令，然后再重新编译
    export GO111MODULE=on
    export GOPROXY=https://goproxy.cn
    # 或者这样设置代理也可以（这样的话永久有效）
    echo "export GO111MODULE=on" >> ~/.profile
    echo "export GOPROXY=https://goproxy.cn" >> ~/.profile
    source ~/.profile
    
    cat << 'EOF' >> /etc/profile
    export PATH=$PATH:/data/source/gno/build
    EOF
    
    source /etc/profile
    

### 创建钱包

**注意请保存你的钱包地址及助记词，助记词若不保存，之后将无法恢复钱包，切记不要随便泄露助记词。**

### 从助记词恢愎钱包

    gnokey add <钱包名> --recover
    

<钱包名> 替换为你自选的钱包名，不需要<>，后面的所有命令也都不需要<>，只需要替换<>内的内容，此命令同时会让你设置一个钱包密码，请记住你设置的钱包登录密码，如果后面忘记密码，也可以用助记词重新恢复钱包。

### 查看现有钱包列表

### 领取测试币

打开水龙头网站 [https://test2.gno.land/faucet](https://test2.gno.land/faucet)

![](https://storage.googleapis.com/papyrus_images/43b4d249f7cf53ba00d4b2fe18229148efcaf1ae49c9bed483ce49c585aa0462.png)

输入你的 Gnoland 钱包地址（ 如 g1f68ckw5yy8nccke6kva0mnf3sg2qv4qm8cf0u0）领取测试币。

**目前**[**水龙头**](https://test2.gno.land/faucet)**只能领50 GNOT，如果想领取更多测试币，需要更换一下vpn的ip，简单的方法就是更换一下vpn的区域，因为水龙头每次领取的时候会检测你的ip，限制了频繁领取。**

### 查看钱包余额

    gnokey query auth/accounts/<你的钱包地址> --remote test2.gno.land:36657
    

### 创建注册帐户

    cd
    
    mkdir gnoland
    
    cd gnoland
    
    account_number=$(gnokey query auth/accounts/<钱包地址>  --remote test2.gno.land:36657  | grep account_number| sed 's/[^0-9]//g')
    
    echo $account_number
    
    sequence=$(gnokey query auth/accounts/<钱包地址>  --remote test2.gno.land:36657  | grep sequence | sed 's/[^0-9]//g')
    
    echo $sequence
    

### 创建注册帐户的Tx

    # 你自定义的用户名必须是6位以上的小写字母，可包含下划线**
    
    gnokey maketx call <钱包地址> --pkgpath "gno.land/r/users" --func "Register" --gas-fee 1000000ugnot --gas-wanted 2000000 --send "200000000ugnot" --args "" --args "<你自定义的用户名>" --args "" > unsigned.tx
    
    # 签名事务Tx
    gnokey sign <钱包地址> --txpath unsigned.tx --chainid test2 --number $account_number --sequence $sequence > signed.tx
    
    # 广播事务Tx
    gnokey broadcast signed.tx --remote test2.gno.land:36657
    

事务广播成功后，就可以在 [https://test2.gno.land/r/users](https://test2.gno.land/r/users) 看到你的用户名。

**如果广播失败，有可能是余额不够 204 GNOT，请确保你已经领取了5次水龙头。**

    rm unsigned.tx 
    rm signed.tx
    

**也有可能是 sequence 错误，请查询并使用最新的 account\_number 和 sequence，删除unsigned.tx和signed.tx，重新完成以上2个步骤（_获取 account\_number 和 sequence，创建注册用户的tx，签名该tx，广播该tx_），重试一次。**

### **创建你自己的留言版**

    # 注意留言版名只能是 英文名，不能包含中文（希望后续版本能够修复这个Bug）
    gnokey maketx call <钱包地址> --pkgpath "gno.land/r/boards" --func "CreateBoard" --gas-fee 1000000ugnot --gas-wanted 10000000 --send 1000000ugnot --broadcast true --chainid test2 --args "<留言版名>" --remote test2.gno.land:36657
    

### 获取刚刚发布的留言版id

    BoardID=$(gnokey query "vm/qeval" --data "gno.land/r/boardsGetBoardIDFromName(\"<留言版名>\")" --remote test2.gno.land:36657  |grep data | sed 's/[^0-9]//g')
    echo $BoardID
    

### 创建发帖内容

    cd gnoland
    sudo cat <<'EOF' >> /gnoland.md
    This is a demo of Gno smart contract programming.
    EOF
    
    # 发帖
    gnokey maketx call <钱包地址> --pkgpath "gno.land/r/boards" --func CreateThread --args $BoardID --args "<帖名>" --args#file "<xxx.md>" --gas-fee 1000000ugnot --gas-wanted 2000000 --chainid test2   --broadcast true  --remote test2.gno.land:36657
    

### 领取任务

[https://test2.gno.land/r/boards:testboard/4](https://test2.gno.land/r/boards:testboard/4)

**在你喜欢的媒体上（Twitter、Medium 或者 Mirror**）用一篇文章（250字以上）描述，为什么你对gno.land 和 gnoland 感兴趣，可以参考

[https://medium.com/@tujiao.eth/gnoland%E9%AB%98%E5%B9%B6%E5%8F%91%E6%99%BA%E8%83%BD%E5%90%88%E7%BA%A6%E5%B9%B3%E5%8F%B0%E4%BB%8B%E7%BB%8D-5575a521d993](https://medium.com/@tujiao.eth/gnoland%E9%AB%98%E5%B9%B6%E5%8F%91%E6%99%BA%E8%83%BD%E5%90%88%E7%BA%A6%E5%B9%B3%E5%8F%B0%E4%BB%8B%E7%BB%8D-5575a521d993)

**在此回复，将你的文章的URL链接作为评论，以获得奖励。**

Gno介绍文章发表成功后，使用如下命令提交

    gnokey maketx call <钱包地址> --pkgpath "gno.land/r/boards" --func "CreateReply" --gas-fee 1000000ugnot --gas-wanted 2000000 --send "" --broadcast true --chainid test2 --args "1" --args "4" --args "4" --args "<文章URL>" --remote test2.gno.land:36657
    

文章链广播成功后，你就能在 [https://test2.gno.land/r/boards:gnoland/4](https://test2.gno.land/r/boards:testboard/4) 看到你的帖子。

到此Gnoland第一个任务已经圆满完成，期待更多任务。

如果您没觉得此文章有用，敬请关注我的推特 [https://twitter.com/tujiao](https://twitter.com/tujiao)

---

*Originally published on [arden](https://paragraph.com/@aptosui/gnoland)*
