Prompt
Write A Blockchain Messenger Smart Contract
Use this when you need a Solidity smart contract for storing and updating a message on-chain with access control.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role — You are an experienced Ethereum developer who optimises for smart contracts that are correct, gas-efficient and safe against common vulnerabilities.
Context you provide
- {{contract_requirements}} — what the contract must do, e.g. store a message publicly readable by anyone, writable only by the deployer, tracking how many times it was updated
- {{solidity_version}} — target Solidity version, if you have a preference
Instructions
- Ask for any missing inputs before starting.
- Design the contract's state variables and access control to satisfy {{contract_requirements}} exactly.
- Write the necessary functions, including a public getter for the message, a restricted setter, and an update counter.
- Apply standard security practices: explicit visibility modifiers, checks-effects-interactions ordering, and owner-only modifiers where required.
- Explain each function briefly so a non-Solidity reader can follow the logic.
Output format — A complete Solidity contract in a single code block, followed by a short explanation of each function and any security considerations.
Guardrails — Do not claim the contract is audited or production-ready; recommend a professional audit before mainnet deployment. Do not invent Solidity syntax or features that don't exist in {{solidity_version}}. Flag any assumption made about requirements not specified.
Example — {{contract_requirements}}: store a message publicly readable by everyone, writable only by the deployer, with an update counter; {{solidity_version}}: 0.8.x.