Skip to content

Commit 0754f43

Browse files
committed
Add study notes for 2025-08-15
1 parent 3275662 commit 0754f43

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

tikpen.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,81 @@ web2前端开发,对web3感兴趣,想加入web3.
1515
## Notes
1616

1717
<!-- Content_START -->
18+
# 2025-08-15
19+
20+
### 搭建本地区块链节点
21+
22+
#### 1.使用docker拉去Geth镜像
23+
24+
​ docker pull ethereum/client-go
25+
26+
#### 2.启动Geth开发链节点
27+
28+
docker run -d --name geth-dev \
29+
-v $(pwd)/data:/root/.ethereum \
30+
-p 8545:8545 -p 30303:30303 \
31+
ethereum/client-go:latest \
32+
--dev \
33+
--http --http.addr 0.0.0.0 --http.port 8545 \
34+
--http.api personal,eth,net,web3 \
35+
--allow-insecure-unlock
36+
37+
------
38+
39+
40+
41+
| 参数 | 作用 |
42+
| -------------------------------- | -------------------------------------- |
43+
| --dev | 启动开发链,自动生成创世区块,快速出块 |
44+
| --http | 启动 HTTP RPC 服务,MetaMask 可访问 |
45+
| --http.addr 0.0.0.0 | 允许容器外访问 |
46+
| --http.port 8545 | RPC 端口 |
47+
| --http.api personal,eth,net,web3 | 开启 RPC API 接口 |
48+
| --allow-insecure-unlock | 允许解锁账户(仅测试用) |
49+
------
50+
51+
52+
#### 3.在MetaMask添加本地网络
53+
54+
打开 MetaMask → 设置 → 网络 → 添加网络:
55+
56+
- **网络名称**:Geth Dev
57+
- **RPC URL**http://127.0.0.1:8545
58+
- **Chain ID**:1337(开发链默认)
59+
- **货币符号**:ETH(可选)
60+
61+
保存后即可连接你的开发链。
62+
63+
#### 4.连接Geth控制台
64+
65+
docker exec -it geth-dev geth attach http://127.0.0.1:8545
66+
67+
###### 常用命令行
68+
69+
- 查看所有账户 eth.accounts(--dev模式下的账户是临时账户)
70+
- 查看余额 eth.getBalance(eth.accounts[0])
71+
72+
#### 5.通过RPC发送币
73+
74+
eth.sendTransaction({
75+
from: eth.accounts[0],
76+
to: "MetaMask地址",
77+
value: web3.toWei(10, "ether")
78+
})
79+
80+
发送成功后会有一个哈希值,可以在Geth控制台调用以下命令查看交易回执(包含是否成功、区块号、Gas 消耗等)
81+
82+
eth.getTransactionReceipt("0x808b51c83e22e7f6489d429d92a89cf8768e624e86782d77a33d76362368a4cf")
83+
84+
{
85+
transactionHash: "0x808b51c83e22e7f6489d429d92a89cf8768e624e86782d77a33d76362368a4cf",
86+
blockHash: "0x5000077b739e05fec262db7b7b0752906b549ce677f6c9efdfb699f2231381aa",
87+
blockNumber: 1,
88+
status: 1, // 1 表示交易成功,0 表示失败
89+
gasUsed: 21000,
90+
...
91+
}
92+
1893
# 2025-08-14
1994

2095
#### 1.搭建配置telegram社群

0 commit comments

Comments
 (0)