1.打开Remix,创建一个空白模板,命名abc.sol

2. 将以下代码粘贴至abc.sol,编译器选择0.8.7,右键点击 complie
pragma solidity ^0.8.0;
// import "hardhat/console.sol";
contract Comments {
// Exposed data structure
struct Comment {
uint32 id;
string topic;
address creator_address;
string message;
uint256 created_at;
}
// Notify users that a comment was added
event CommentAdded(Comment comment);
uint32 private idCounter;
mapping(string => Comment[]) private commentsByTopic;
// Fetch a list of comments for a topic
function getComments(string calldata topic) public view returns(Comment[] memory) {
return commentsByTopic[topic];
}
// Persist a new comment
function addComment(string calldata topic, string calldata message) public {
Comment memory comment = Comment({
id: idCounter,
topic: topic,
creator_address: msg.sender,
message: message,
created_at: block.timestamp
});
commentsByTopic[topic].push(comment);
idCounter++;
emit CommentAdded(comment);
}
// Delete comment
function deleteComment(string calldata id) public {}
}
3.如下图所示进行合约部署,切换到condor链,连接Metamask, 单击deploy. 支付gas后复制生成的合约代码,下一步用到。

3. 打开replit , 点击fork

4. 找到 hooks>useCommentsContract.ts 文件,用刚刚生成的合约,替换第160行的合约,之后运行


5.复制url 去discord提交(提交时候,repl得处于运行状态,等拿到角色后可以关闭网页)

