返回文档列表
🚀 文档

快速开始

快速开始使用本知识库,了解基本概念和使用方法

部署指南

合约开发和测试都通过了?接下来部署到测试网或主网。

编译

forge build

部署

部署到本地测试网

forge create src/UniswapV3Factory.sol:UniswapV3Factory \
    --rpc-url http://127.0.0.1:8545 \
    --private-key <你的私钥>

部署到测试网

forge create src/UniswapV3Factory.sol:UniswapV3Factory \
    --rpc-url https://sepolia.infura.io/v3/<YOUR_KEY> \
    --private-key <你的私钥>

验证部署

部署成功后,可以用 Etherscan 验证合约代码:

forge verify-contract <合约地址> src/UniswapV3Factory.sol:UniswapV3Factory \
    --etherscan-api-key <API_KEY>

常见问题

部署失败:out of gas:增加 gas limit 试试。

验证失败:确认编译器版本和优化器设置与部署时一致。