Skip to content

Commit a2bb657

Browse files
authored
Update Elorze.md
1 parent f763d5c commit a2bb657

File tree

1 file changed

+83
-1
lines changed

1 file changed

+83
-1
lines changed

Elorze.md

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ npx hardhat node
611611
612612
十二、
613613
在新终端中,进入到`/optimism/packages/contracts-bedrock`:
614-
运行以下命令,会在项目根目录生成 deploy-config/local.json:
614+
运行以下命令,为部署准备好参数。会在项目根目录生成 deploy-config/local.json:
615615
```bash
616616
npx hardhat generate-deploy-config --name local
617617
```
@@ -623,7 +623,89 @@ npx hardhat generate-deploy-config --name local
623623
624624
625625
### 2025.04.11
626+
OP Stack 的部署需要本地 Hardhat 节点保持“运行状态”,否则部署就会失败。
627+
确认是否需要重启本地节点:
628+
```bash
629+
curl -X POST http://127.0.0.1:8545 \
630+
-H "Content-Type: application/json" \
631+
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
632+
```
633+
如果看到一个像 "result": "0x..." 的响应,就表示节点还在运行。
634+
如果看到 Connection refused 或 Failed to connect,说明节点已经关闭了,需要重新运行。
635+
636+
如果节点已关闭,重新启动的方法如下:
637+
1.**打开虚拟机,进入昨天运行 Hardhat 节点的项目目录:**
638+
```bash
639+
cd /home/user/optimism/optimism/packages/contracts-bedrock
640+
```
641+
2.**重新启动本地 Hardhat 节点:**
642+
```bash
643+
npx hardhat node
644+
```
645+
🔁 注意:这个节点是临时的,重启之后所有之前部署的合约都会“消失”,你需要重新部署一遍。
646+
**3.然后在另一个终端窗口里重新部署合约。这里先下载下依赖:**
647+
```bash
648+
pnpm install
649+
650+
npm install -D ts-node
651+
```
652+
653+
654+
然后部署:
655+
```bash
656+
npx ts-node ./scripts/deploy.ts \
657+
--network getting-started \
658+
--deploy-config ./deploy-config/local.json
659+
```
660+
661+
626662
一、部署 Layer 1 合约
663+
**1.创建部署脚本文件**
664+
在 contracts-bedrock/ 目录下创建一个新文件:
665+
```bash
666+
cd ~/optimism/optimism/packages/contracts-bedrock
667+
nano deploy.js
668+
```
669+
粘贴以下内容:
670+
```js
671+
const { ethers } = require("hardhat");
672+
673+
async function main() {
674+
console.log("🚀 Connecting to local Hardhat network...");
675+
const [deployer] = await ethers.getSigners();
676+
console.log("✅ Deployer address:", deployer.address);
677+
678+
// 示例:部署 SystemConfig(contracts/SystemConfig.sol)
679+
const SystemConfig = await ethers.getContractFactory("SystemConfig");
680+
const systemConfig = await SystemConfig.deploy(
681+
2, // _overhead
682+
3, // _scalar
683+
deployer.address, // _batcherHash
684+
deployer.address, // _gasLimitOwner
685+
deployer.address, // _unsafeBlockSigner
686+
"0x4200000000000000000000000000000000000000" // _configOwner
687+
);
688+
await systemConfig.deployed();
689+
console.log("✅ SystemConfig deployed to:", systemConfig.address);
690+
}
691+
692+
main().catch((error) => {
693+
console.error("❌ Deployment failed:", error);
694+
process.exit(1);
695+
});
696+
```
697+
**2.安装依赖**
698+
```bash
699+
npm install --save-dev hardhat ethers
700+
```
701+
**3.确保本地节点运行中**
702+
这个前面已经确定了。
703+
**4.运行部署脚本!**
704+
回到放 deploy.js 的那个目录:
705+
```bash
706+
node deploy.js
707+
```
708+
627709
628710
629711

0 commit comments

Comments
 (0)