File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,46 @@ web2前端开发,想要转型web3,喜欢游戏、运动,目前base杭州
1515## Notes
1616
1717<!-- Content_START -->
18+ # 2025-08-19
19+
20+ 完成了部署合约到 Sepolia 测试网,并成功发送消息,看到了日志
21+
22+ ``` solidity
23+ // SPDX-License-Identifier: MIT
24+ pragma solidity ^0.8.0;
25+
26+ contract MessageBoard {
27+ // 保存所有人的留言记录
28+ mapping(address => string[]) public messages;
29+
30+ // 留言事件,便于检索器和区块链浏览器追踪
31+ event NewMessage(address indexed sender, string message);
32+
33+ // 构造函数,在部署时留言一条欢迎词
34+ constructor() {
35+ string memory initMsg = "Hello ETH Pandas";
36+ messages[msg.sender].push(initMsg);
37+ emit NewMessage(msg.sender, initMsg);
38+ }
39+
40+ // 发送一条留言
41+ function leaveMessage(string memory _msg) public {
42+ messages[msg.sender].push(_msg); // 添加到发言记录
43+ emit NewMessage(msg.sender, _msg); // 发出事件
44+ }
45+
46+ // 查询某人第 n 条留言(从 0 开始)
47+ function getMessage(address user, uint256 index) public view returns (string memory) {
48+ return messages[user][index];
49+ }
50+
51+ // 查询某人一共发了多少条
52+ function getMessageCount(address user) public view returns (uint256) {
53+ return messages[user].length;
54+ }
55+ }
56+ ```
57+
1858# 2025-08-18
1959
2060报名参加了休闲黑客松。
You can’t perform that action at this time.
0 commit comments