-
Notifications
You must be signed in to change notification settings - Fork 75
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
base: main
Are you sure you want to change the base?
部署 univ3 #118
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Uniswap V3 pool 合约部署 | ||
|
||
UniswapV3Factory 合约主要用来创建不同代币对的流动性池子合约,合约的 createPool 函数new UniswapV3Pool 部署新池子合约。所以通过部署UniswapV3Factory来创建Pool合约池子 | ||
|
||
一、使用Foundry部署合约 | ||
|
||
1、安装Foundry | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 可以简单介绍一下 Foundry |
||
|
||
curl -L https://foundry.paradigm.xyz | bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 代码要用 ``` 框起来 |
||
|
||
foundryup // 安装foundry | ||
|
||
foundry | ||
|
||
二、克隆合约代码仓库 git clone https://github.com/Uniswap/v3-core.git | ||
|
||
1、添加 .env 文件 // 用于存储 链的RPC节点、 部署钱包私钥、 浏览器API key | ||
|
||
里面填入 ```SEPOLIA_RPC_URL=https://1rpc.io/sepolia | ||
PRIVATE_KEY=0xadef625bf2530e93c80873d633fef9daa9adae04ca5f690663136c2c45033dd7 | ||
ETHERSCAN_API_KEY=6R9K4BAA2RHMRD5NXQB5YKKCNGQ8URW5Y8``` | ||
|
||
执行source .env 保存 // 更新环境变量,才能使用Foundry | ||
|
||
2、添加foundry.toml 文件 // Foundry框架的配置文件 | ||
|
||
里面填入 | ||
|
||
``` | ||
[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文件, // deploy.sol文件是Foundry 的部署脚本代码 | ||
|
||
填入 | ||
|
||
```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(); // UniswapV3Factory是部署的合约名 | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} | ||
|
||
``` | ||
|
||
4、安装库 : forge install foundry-rs/forge-std --no-commit // 安装Foundry 库 | ||
|
||
最后运行命令进行部署 : | ||
|
||
forge script src/deploy.sol:Deploy --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcast --verifier etherscan $ETHERSCAN_API_KEY -vvvv --verify // 部署Factory 上链交易 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 整体内容还是太单薄了,要多一些解释 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.