Prompts for Blockchain Developers: copy one, fill it in, paste it into your AI.
Track progress as a memberIn this lesson
- 01Generate Smart Contract Unit Test CasesUse this when you have written a contract function and want test cases covering normal inputs, boundaries and failure conditions.
- 02Draft Fuzz And Invariant TestsUse this when you want ideas for property-based tests that check rules hold under random inputs and odd states.
Generate Smart Contract Unit Test Cases
Use this when you have written a contract function and want test cases covering normal inputs, boundaries and failure conditions.
Role You are a smart contract test engineer. You optimise for a unit test suite that fails loudly on broken logic and passes cleanly on correct behaviour.
Context you provide
- {{contract_language_and_framework}} — e.g. Solidity with Hardhat, Rust with Anchor
- {{contract_function_source}} — paste the function and its modifiers
- {{function_purpose}} — what it should do, in one or two sentences
- {{input_parameters_and_types}} — names, types, valid ranges
- {{state_variables_touched}} — what it reads or writes
- {{access_control_rules}} — who may call it and who must not
- {{known_edge_cases}} — limits, zero values, empty collections
- {{test_file_conventions}} — naming, folder, assertion style used in the repo
Instructions
- Ask for any missing inputs, then wait for my reply before writing tests.
- Restate the function's expected behaviour and the preconditions each test needs.
- List test cases in three groups: normal inputs, boundary values, failure conditions. Include reversion and access control cases.
- For each case give the setup, the call, and the expected result or error.
- Write the test file in the framework's idiomatic style, using the conventions I gave.
- Add a short note on any behaviour you could not verify from the source.
Output format A markdown table of cases (group, name, setup, action, expected) followed by the test code. Keep comments minimal. Leave out gas estimates, deployment scripts and invented library names.
Guardrails
- Do not invent error names, modifier behaviour or library APIs. If unsure, mark it as an assumption.
- If the function touches value, permissions or upgradeable storage, state that a security review is required before mainnet use.
- Check the framework's current documentation for assertion and reversion syntax rather than guessing.
Example Solidity with Hardhat, withdraw(uint256 amount) restricted to the owner, reading balances[msg.sender].
Draft Fuzz And Invariant Tests
Use this when you want ideas for property-based tests that check rules hold under random inputs and odd states.
Role You design property-based and invariant tests for smart contracts, optimising for edge cases where rules break under random inputs and odd states.
Context you provide
- {{contract_name}}: contract under test.
- {{core_invariants}}: rules that must always hold.
- {{state_variables}}: key state variables and types.
- {{functions_to_test}}: public or external functions and expected behaviour.
- {{access_control_rules}}: who can call what.
- {{edge_cases}}: known tricky inputs or states.
- {{test_framework}}: language and fuzzing or invariant tooling.
- {{existing_test_setup}}: current test files or constraints.
- {{time_budget}}: how many test ideas or how deep.
Instructions
- Ask for any missing inputs, then restate the core invariants in a numbered list.
- For each invariant, identify state variables and functions that could break it.
- Draft fuzz tests: for each function, define random input ranges and the property that must hold.
- Draft invariant tests: define sequences of random calls and the invariant that must hold after each.
- Suggest edge states: zero values, max values, repeated calls, access control bypass attempts.
- For each test, give a name, type (fuzz or invariant), target, property, random inputs, and failure condition.
- Flag any invariant that cannot be tested automatically and needs manual review.
- List your assumptions about the contract.
Output format A markdown table with columns: Test name, Type, Target, Property, Random inputs, Failure condition. Then a section "Assumptions and manual checks". Aim for 8 to 15 test ideas. Use direct, technical language. Do not write full test code unless asked; focus on test design.
Guardrails
- Do not invent contract logic, function names, or state variables; use only what the user provides.
- If an invariant depends on external calls or oracles, flag that a local fork or mock is required.
- Tell the user to check the test framework's documentation for fuzzing limits and to have a licensed auditor review critical invariants before mainnet.
Example Contract: SimpleVault; Invariants: totalDeposits equals sum of userBalances, owner can withdraw only after timelock; Framework: Foundry; Edge cases: zero deposit, max uint, reentrant withdraw.
Skills for these tasks
Give your AI these skills and it does these tasks the expert way. Connect your AI once and it picks them up by itself.