跳到内容
Logo
开发者快速入门

Zcash 开发
快速入门

快速开始进行 Zcash 开发。选择你的技术栈并按照指南操作。

安装

依赖项

bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
sudo apt update
sudo apt install libclang-dev clang pkg-config openssl protobuf-compiler npm

从源码构建

bash
git clone https://github.com/ZcashFoundation/zebra.git
cd zebra
git checkout v6.3.0
cargo build --release --bin zebrad
export PATH="$PATH:$(pwd)/target/release"

或者

bash
cargo install --git https://github.com/ZcashFoundation/zebra --tag v6.3.0 zebrad
2

运行 zebrad

初始设置

创建配置目录

bash
zebrad generate -o ~/.config/zebrad.toml

zebrad.toml

toml
[consensus]
checkpoint_sync = true

[mempool]
eviction_memory_time = "1h"
tx_cost_limit = 80000000

[network]
cache_dir = true
crawl_new_peer_interval = "1m 1s"
listen_addr = "[::]:8233"
network = "Mainnet"
peerset_initial_target_size = 25

[rpc]
listen_addr = "127.0.0.1:8232"
cookie_dir = "/home/your_username/.cache/zebra"
enable_cookie_auth = false

[state]
cache_dir = "/home/your_username/.cache/zebra" # (Change to store in external SSD)
delete_old_database = true
ephemeral = false

[sync]
checkpoint_verify_concurrency_limit = 1000
download_concurrency_limit = 50
full_verify_concurrency_limit = 20

[tracing]
buffer_limit = 128000
use_color = true

启动 zebrad

命令行

bash
zebrad start
# Or with specific config
zebrad -c ~/.config/zebrad.toml start

重要说明

  • 首次运行会下载完整区块链(约 250 GB)
  • 初始同步可能需要数小时
  • 请妥善保管你的 zebrad.toml 并确保其私密性
3

连接 lightwalletd

lightwalletd 是一个为 Zcash 区块链提供轻量级接口的服务器,专为无需运行完整节点的移动端和桌面钱包设计。

安装

前置条件

bash
# Install Go
sudo apt install golang-go
# Or download from golang.org

构建 lightwalletd

bash
git clone https://github.com/zcash/lightwalletd.git
cd lightwalletd
go build
make
make install
export PATH=$PATH:~/go/bin

配置

基础设置(主网)

bash
cat > ~/.config/zcash.conf << EOF
rpcport=8232
rpcbind=127.0.0.1
rpcuser=your_rpc_username
rpcpassword=your_rpc_password
EOF

基础设置(测试网)

bash
cat > ~/.config/zcash.conf << EOF
testnet=1
rpcport=18238
rpcbind=127.0.0.1
rpcuser=your_rpc_username
rpcpassword=your_rpc_password
EOF

运行

bash
lightwalletd --zcash-conf-path ~/.config/zcash.conf --data-dir ~/data/zebrad/.cache/lightwalletd --log-file ~/.local/state/lwd.log --no-tls-very-insecure

后续步骤与资源