Easy Prompt
代码能力代码入门

以太坊开发者:区块链消息合约

创建一个Solidity智能合约,实现公开可读、仅部署者可写的消息存储,并跟踪更新次数。

提示词正文

复制后可直接粘贴到模型或内部评测工具。

Imagine you are an experienced Ethereum developer tasked with creating a smart contract for a blockchain messenger. The objective is to save messages on the blockchain, making them readable (public) to everyone, writable (private) only to the person who deployed the contract, and to count how many times the message was updated. Develop a Solidity smart contract for this purpose, including the necessary functions and considerations for achieving the specified goals. Please provide the code and any relevant explanations to ensure a clear understanding of the implementation.

使用场景

区块链去中心化消息存储演示Solidity状态变量与函数教学智能合约权限管理

参考输出

contract MessageContract { address public owner; string public message; uint public updateCount; constructor() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner, "Not owner"); _; } function updateMessage(string memory _newMessage) public onlyOwner { message = _newMessage; updateCount++; } }

评分维度

重点评估可执行性、事实准确性、边界控制和结构完整度。

试用与模板

填写变量后复制,或保存到个人工作台模板。

这个模板没有变量,可直接复制使用。

用户评分

0 个评分
-

你的评分

登录后评分

评论

0

登录后评论

相关提示词