Solidity REPL
RUNNABLE SOLIDITY EXAMPLES

Start with a real Solidity question.

Open any example to understand the use case, inspect the exact code and expected result, then run it as a new Solidity REPL session.

10 CASES

Math & units

Confirm integer arithmetic, overflow behavior, bit operations, and Solidity units.

10 CASES

Encoding & crypto

Inspect hashes, ABI bytes, selectors, calldata, and signature recovery.

09 CASES

Syntax & control flow

Practice branches, loops, named calls, boolean expressions, and tuple assignments.

17 CASES

Types & storage

Work with arrays, structs, enums, mappings, and raw storage effects.

Ready to runDynamic arraysCreate, change, and inspect an in-memory array.Ready to runFixed arraysTry a fixed-size array literal and read its items.Ready to runStruct valuesCreate a struct and inspect each field immediately.Ready to runEnumsMove between a named enum state and its numeric value.Ready to runMapping storageWrite a mapping and inspect the resulting storage change.Ready to runUser-defined value typeWrap and unwrap a custom numeric Solidity type.Ready to runStorage array push and popAppend, update, and remove values from a dynamic storage array.Ready to runMemory reference aliasingSee two memory variables refer to the same array allocation.Ready to runLocal storage referenceModify a state array through a local storage reference.Ready to runDelete and default valuesReset value types to their Solidity defaults with delete.Ready to runInternal function valuesPass a Solidity function as a typed value to another function.Solidity 0.8.18Named nested mappingUse named mapping keys and values in a nested allowance table.Ready to runType informationInspect integer limits, contract bytecode, and an interface identifier.Ready to runBytes storage membersPush, index, and pop individual bytes in dynamic storage.Ready to runCalldata array sliceRemove a four-byte selector and decode the remaining calldata.Ready to runExplicit type conversionsConvert between integer widths, fixed bytes, and payable addresses.Ready to runExternal function membersInspect the address and selector carried by an external function value.
24 CASES

Contracts & calls

Deploy contracts, follow external calls, use imports, and decode events.

Ready to runHelper functionDeclare a function beside loose statements and call it directly.Ready to runDeploy and call a contractCreate a contract in memory and call it in the same REPL session.Ready to runInheritance and overrideCheck virtual functions, super calls, and overrides.Ready to runImport a local libraryLoad a ready-made second file and use its library function.Ready to runUse an imported repository fileImport a library from a repository-shaped path and call it from the REPL.Ready to runInterface callCast a deployed contract to an interface and call it.Ready to runEmit and decode an eventSee indexed and normal event arguments beside their raw topics.Ready to runTry and catch a revertCall a contract that reverts and handle the result without ending the run.Ready to runConstant and immutable stateCompare a compile-time constant with a constructor-assigned immutable.Ready to runFunction modifierRun a function body through a reusable access-control modifier.Ready to runFunction overloadingResolve functions with the same name from their parameter types.Ready to runAbstract contract implementationImplement an abstract virtual function in a concrete contract.Ready to runLibrary using-for directiveAttach a library function to uint256 as a member function.Ready to runReceive and fallback functionsCompare an empty call with unmatched calldata on the same contract.Ready to runSalted contract creationDeploy a contract with CREATE2 syntax and a deterministic salt.Ready to runLow-level static callEncode calldata, use staticcall, and decode the returned bytes.Solidity 0.8.19User-defined operatorAttach the plus operator to a user-defined value type.Solidity 0.8.28Transient storageSet and clear transaction-scoped state with a transient variable.Ready to runSelective import aliasesRename imported symbols and use a file-level constant from another source.Ready to runBase constructor argumentsPass constructor arguments from a derived contract to its base.Ready to runDelegatecall storage contextRun another contract’s code while writing to the caller’s storage.Ready to runExternal call optionsAttach value and gas options to a typed external function call.Ready to runAnonymous eventEmit an anonymous event and inspect its indexed and data fields.Solidity 0.8.29Custom storage layout baseMove a contract’s first storage slot to a chosen base position.
08 CASES

Context & forks

Control transaction and block fields or read a fixed point in live chain state.

10 CASES

Debugging & errors

Reproduce reverts, inspect panic data, and follow calls and EVM instructions.

08 CASES

VM helpers

Set balances, storage, time, block numbers, bytecode, labels, and persistent state.