# CAT20铸造手把手教程-从零开始新手指南 **Published by:** [青澈君](https://paragraph.com/@chuana/) **Published on:** 2024-09-14 **URL:** https://paragraph.com/@chuana/cat20 ## Content 本人主要分享撸毛|打新|套利相关项目信息,欢迎关注我的推特@qingchejun https://twitter.com/qingchejun UNISAT上的FBCAT-20 MINT结束了,我重新梳理了一个教程,本文主要内容如下: • 服务器部署与环境配置 • CAT Protocol 安装与编译 • Docker 容器运行 • 钱包创建与管理 • 节点同步状态监控 • 手动铸造操作 • 自动化铸造工具使用 适合: 初学者到中级用户,预计1~2小时可完成。0.准备工作部署服务器:我用的是阿里云的 Ubuntu 服务器。选择适当的配置,确保有足够的存储空间(2CPU+4G+至少 50GB硬盘),按量付费会比较灵活,服务器购买入口(未夹带私货):https://ecs-buy.aliyun.com/ecs?spm=5176.8789780.J_4267641240.2.7c4e39fbB77NYx#/custom/postpay/ap-northeast-1,按下图选择即可,未注明的按默认处理2. 连接到服务器:使用 SSH 客户端(如 PuTTY 或终端)连接到您的服务器。 以通过终端(Terminal)使用SSH命令连接到服务器为例: 基本格式为: ssh 用户名@服务器IP地址,例如: ssh root@123.456.789.10 如果是首次连接到该服务器,你可能会看到类似这样的提示: The authenticity of host '123.456.789.10 (123.456.789.10)' can't be established. ECDSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. Are you sure you want to continue connecting (yes/no/[fingerprint])? 输入 yes 并按回车键。 输入服务器密码 系统会提示你输入密码。输入时,屏幕上不会显示任何字符,这是正常的安全措施。 输入完成后按回车键,即可登录。 3. 更新系统(必做):sudo apt-get update && sudo apt-get upgrade -y 说明:这个命令会更新系统软件包列表并升级已安装的软件包。1. 环境配置安装 Docker、docker-compose 和 Node.js 环境。sudo apt-get install docker.io -y VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep -Po '"tag_name": "\K.*\d') DESTINATION=/usr/local/bin/docker-compose sudo curl -L https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m) -o $DESTINATION sudo chmod 755 $DESTINATION sudo apt-get install npm -y sudo npm install n -g sudo n stable sudo npm i -g yarn 说明:这些命令会依次安装 Docker、docker-compose、npm、Node.js 和 Yarn。每个命令可能需要一些时间来完成,请耐心等待。 验证安装:docker --version docker-compose --version node --version npm --version yarn --version 说明:这些命令会显示各个工具的版本号。如果正确安装,应该能看到版本信息而不是错误消息。2. 拉取 Git 仓库和编译git clone https://github.com/CATProtocol/cat-token-box cd cat-token-box yarn install yarn build 说明:git clone 会下载 CAT Protocol 的源代码到当前目录。cd cat-token-box 进入下载的目录。yarn install 安装项目依赖,这可能需要几分钟。yarn build 编译项目,也可能需要一些时间。3.运行 Docker 容器3.1 运行 Fractal 节点:cd ./packages/tracker/ sudo chmod 777 docker/data sudo chmod 777 docker/pgdata sudo docker-compose up -d 说明:cd ./packages/tracker/ 进入 tracker 目录。chmod 命令更改目录权限,确保 Docker 可以访问这些目录。docker-compose up -d 启动 Fractal 节点。-d 参数使容器在后台运行。3.2 运行 CAT Protocol 索引器:cd ../../ sudo docker build -t tracker:latest . sudo docker run -d \ --name tracker \ --add-host="host.docker.internal:host-gateway" \ -e DATABASE_HOST="host.docker.internal" \ -e RPC_HOST="host.docker.internal" \ -p 3000:3000 \ tracker:latest 说明:cd ../../ 返回到项目根目录。docker build 构建 Docker 镜像。docker run 运行 CAT Protocol 索引器。确保 3000 端口未被占用。4. 创建钱包创建配置文件:cd packages/cli nano config.json 说明:nano config.json会打开 nano 文本编辑器。 在 config.json 中添加以下内容:{ "network": "fractal-mainnet", "tracker": "http://127.0.0.1:3000", "dataDir": ".", "maxFeeRate": 30, "rpc": { "url": "http://127.0.0.1:8332", "username": "bitcoin", "password": "opcatAwesome" } } 保存并退出:在 nano 中,按 Ctrl+X,然后按 Y 确认保存,最后按 Enter 确认文件名。 创建钱包:yarn cli wallet create 说明:这将创建一个新的钱包。执行后,会看到上图所示的一串助记词,请务必安全地保存好。5. 查看节点同步状态输入以下命令,可以随时查看全节点同步情况sudo docker exec tracker-bitcoind-1 /usr/local/bin/bitcoin-cli -rpcuser=bitcoin -rpcpassword=opcatAwesome getblockchaininfo 6. 进行铸造(Mint)操作确保节点已完全同步后,可以使用以下命令进行铸造:sudo yarn cli mint -i 45ee725c2c5993b3e4d308842d87e973bf1951f5f7a804b21e4dd964ecd12d6b_0 5 说明:请确保使用正确的输入(UTXO)。5 表示铸造 5 个 CAT 代币,您可以根据需要调整这个数字。执行此命令可能需要一些时间,取决于网络状况。可以在最后加上“--fee-rate 数字”,自定义GAS,以500GAS为例就是这样sudo yarn cli mint -i 45ee725c2c5993b3e4d308842d87e973bf1951f5f7a804b21e4dd964ecd12d6b_0 5 --fee-rate 500 7. 自动化 Mint 工具使用说明 为了简化 Mint 过程,我编写了一个可自动匹配实时GAS的全自动化MINT工具,实现了自动循环MINT CAT 代币。 主要组件:get_fee_rate.py:获取当前 GAS 费率的 Python 脚本script.sh:执行 Mint 操作的 主脚本使用方法确保 get_fee_rate.py 和 script.sh 在同一目录下。安装依赖: pip install playwright playwright install chromium 说明:这会安装必要的 Python 库和浏览器。给予 script.sh 执行权限: chmod +x script.sh 说明:这使得脚本可以被执行。运行脚本: ./script.sh 说明:这会启动自动化 Mint 过程。脚本会持续运行,自动处理 Mint 操作。get_fee_rate.pycd cat-token-box 进入cat-token-box目录。 复制以下内容到文件中:from playwright.sync_api import sync_playwright import sys def get_fractal_fee_rate(): with sync_playwright() as p: browser = p.chromium.launch(headless=True) page = browser.new_page() try: page.goto('https://explorer.unisat.io/fractal-mainnet/block') page.wait_for_load_state('networkidle') xpath = '//*[@id="__next"]/div[1]/div[2]/div[2]/div/div/span[1]' fee_element = page.wait_for_selector(xpath, state="attached", timeout=30000) if fee_element: text = fee_element.inner_text().strip() if text.isdigit(): fee = int(text) adjusted_fee = int(fee * 1.03) # 将费率提高 3% print(f"{fee},{adjusted_fee}") return else: print(f"提取的文本不是数字: {text}", file=sys.stderr) else: print("未找到匹配的GAS费率元素", file=sys.stderr) except Exception as e: print(f"获取Fractal网络GAS费率时出错: {e}", file=sys.stderr) finally: browser.close() print("error") if __name__ == "__main__": get_fractal_fee_rate() 保存并退出:按 Ctrl+X,然后 Y,最后 Enter。script.sh创建文件:nano script.sh 复制以下内容到文件中:#!/bin/bash last_used_index=-1 get_next_input() { local base_txid="45ee725c2c5993b3e4d308842d87e973bf1951f5f7a804b21e4dd964ecd12d6b" last_used_index=$((last_used_index + 1)) echo "${base_txid}_${last_used_index}" } get_gas_fee() { local result=$(python3 get_fee_rate.py 2>/dev/null) if [[ $result == *","* ]]; then IFS=',' read -ra FEES <<< "$result" echo "${FEES[1]}" else echo "" fi } while true; do current_fee=$(get_gas_fee) if [[ $current_fee =~ ^[0-9]+$ ]]; then echo "当前GAS费用: $current_fee sats/vB" new_input=$(get_next_input) echo "尝试使用输入: $new_input" command="sudo yarn cli mint -i $new_input 5 --fee-rate $current_fee" output=$($command 2>&1) if echo "$output" | grep -q "No token found for tokenId"; then echo "无可用UTXO,尝试下一个输入" continue elif echo "$output" | grep -q "Start merging your \[CAT\] tokens"; then echo "Mint操作开始..." if echo "$output" | grep -q "mint failed"; then echo "Mint操作失败,等待60秒后重试" sleep 60 else echo "Mint操作成功" fi else echo "未知错误,等待60秒后重试" sleep 60 fi else echo "无法获取有效的GAS费用,等待10秒后重试" sleep 10 fi sleep 1 done 保存并退出:按 Ctrl+X,然后 Y,最后 Enter。 至此,在终端中运行 ./script.sh,回车即可。 本教程完。本文参考教程: https://mirror.xyz/3p-labs.eth/0IWdR6toFMACCRZTwTAF3XFAv2TiEAPEAHqzVF707g8 ## Publication Information - [青澈君](https://paragraph.com/@chuana/): Publication homepage - [All Posts](https://paragraph.com/@chuana/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@chuana): Subscribe to updates - [Twitter](https://twitter.com/qingchejun): Follow on Twitter