Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

部署 univ3 #118

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions demo-contract/Pool contract deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Uniswap V3 pool 合约部署
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该是新建一个 T002_UniswapV3Deploy 这样的目录,单独放进去。然后再仓库的 readme 中添加对应的链接。算是一个独立的文档。


一、使用Foundry部署合约

1、安装Foundry
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没用 markdown 的语法吗?代码应该用 ``` 包起来


curl -L [https://foundry.paradigm.xyz](https://foundry.paradigm.xyz/) | bash

foundryup // 安装foundry

foundry

二、克隆合约代码仓库 git clone https://github.com/Uniswap/v3-core.git

1、添加 .env 文件
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.env 应该写成 .env 会好一点。


里面填入 SEPOLIA_RPC_URL=https://1rpc.io/sepolia
PRIVATE_KEY=0xadef625bf2530e93c80873d633fef9daa9adae04ca5f690663136c2c45033dd7
ETHERSCAN_API_KEY=6R9K4BAA2RHMRD5NXQB5YKKCNGQ8URW5Y8

2、添加foundry.toml 文件
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

除了具体的步骤以外,要做一些说明和解释,每个文件是干嘛的,每个配置大概是干嘛,整体的逻辑大概是什么样的


里面填入

```
[profile.default]
solc_version = "0.7.6"
src = "src"
out = "out"
libs = ["lib"]
extra_output = ["storageLayout"]
build_info = true
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
[rpc_endpoints]
sepolia = "${SEPOLIA_RPC_URL}"

[etherscan]
sepolia = { key = "${ETHERSCAN_API_KEY}" }
```

3、添加src 文件夹在里面添加 deploy.sol文件,

填入

```solidity
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.6;

import {Script, console} from "forge-std/Script.sol";
import {UniswapV3Factory} from "./../contracts/UniswapV3Factory.sol";

contract Deploy is Script {
UniswapV3Factory public factory;

function setUp() public {}

function run() public {
vm.startBroadcast();

factory = new UniswapV3Factory();

vm.stopBroadcast();
}
}

```

4、安装库 : forge install foundry-rs/forge-std --no-commit

最后运行命令进行部署 :

forge script src/deploy.sol:Deploy --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcast --verifier etherscan $ETHERSCAN_API_KEY -vvvv --verify // 合约不需要开源就去掉后面的参数