Solidity REPL
GUIDE7 min readMaintained by @Bitmay

Prototype Solidity behavior before creating a project

A fragment is most useful when it answers a design question before project setup obscures the behavior. This guide starts with one semantic claim, tests the cases that could invalidate it, and turns the result into Solidity you can reuse elsewhere.

OUTCOMEA compact compatibility experiment with explicit assumptions and source that can move into a contract or test suite.
  • Isolate language behavior from framework and deployment setup
  • Test meaningful boundaries under the intended compiler
  • Grow a fragment into functions and contracts without restarting
  • Carry the proven behavior into project tests
01

Reduce the design question to one expression

Remove deployment, access control, and framework code until only the behavior under discussion remains. For a fee formula, declare the amount and rate, then evaluate the expression. For encoding, begin with the exact types and values the receiving function expects.

Write the expected result before expanding the experiment. If integer rounding, sign, units, or byte layout could matter, include the type explicitly. The REPL supplies the surrounding source, while the selected compiler applies normal Solidity semantics.

uint256 amount = 10 ether
uint256 share = amount * 7 / 100
share
02

Test the cases that could change the answer

A happy-path value demonstrates one case. A useful prototype also checks the boundary that could reverse the decision: zero, a rounding threshold, a negative operand, a maximum integer, malformed bytes, or a failed conversion. Keep each case visible so reviewers can compare them.

When an operation is expected to fail, the revert is part of the result. Compare checked and unchecked arithmetic deliberately, and distinguish a compiler error from a runtime panic. This turns a snippet into evidence about the behavior you plan to rely on.

03

Select the compiler before drawing a conclusion

Syntax and runtime behavior can differ across compiler generations. Select the version required by the code or deployment, then rerun the complete transcript. Solidity REPL supports catalog releases from 0.4.0 through the latest available release and keeps the chosen version with the session.

If changing versions breaks an earlier entry, treat that failure as a compatibility result. Record the versions that matter instead of rewriting the code until the difference disappears. Replay source lets you inspect the wrapper produced for that compiler generation.

04

Grow the experiment without losing the claim

Add a helper when multiple inputs need the same operation. Add a struct, interface, library, or contract only when the question depends on it. Earlier entries remain visible, so you can see when a pure expression became contract behavior.

Move to Source mode when editing the complete document is clearer than maintaining sequential entries. The REPL preserves the reasoning path; Source mode keeps a permanent editor and details panel for the complete program.

function shareOf(uint256 amount, uint256 bps) pure returns (uint256) {
  return amount * bps / 10_000;
}

shareOf(10 ether, 700)
05

Carry the result into the project

Inspect Replay source and copy the smallest implementation that passed every relevant case. In the destination project, turn the inputs and expected results into tests under the same compiler and optimizer assumptions. Add integration setup after the language behavior remains covered directly.

Keep the exported session with a review or issue when the reasoning matters. It shows why the implementation was chosen and preserves boundary cases and compiler assumptions that a final code diff may not explain.

FAQ

Common questions

Is wrapper-free Solidity different from normal Solidity?

No. Solidity REPL generates a valid surrounding document, then uses the selected Solidity compiler. Types, arithmetic, encoding, errors, and EVM execution follow that compiler’s rules.

When is the prototype complete?

It is complete when the original claim, meaningful boundary cases, compiler, and expected failure behavior are visible and reproducible. Project-specific integration can then be tested separately.

Can I inspect the generated wrapper?

Yes. Replay source shows the cumulative Solidity document that was compiled, so the convenience layer does not remain a hidden assumption.