Menu

Solidity Playground

Write, run, and share code snippets — no setup required.

Contract.sol
Click Run to see the output here.
ArgsValues passed to your contract’s main(...) function. The runner ABI-encodes them based on the parameter types.
No arguments. Click "Add arg" to pass one.

Try Solidity in the browser

Solidity is the language of Ethereum smart contracts. It runs on the EVM — the same virtual machine that secures hundreds of billions of dollars on mainnet and powers most L2s. This playground gives you a Monaco editor wired to a sandboxed solc + geth EVM, so you can write a contract, press Run, and see exactly what would happen on-chain: console.log output, emitted events, and the final state of your storage variables — without deploying anything, paying gas, or touching a wallet.

Solidity is unusual in a few ways worth noticing as you start. Storage is permanent by default — anything assigned to a state variable persists; anything inside a function is gone when the call returns. Events are how contracts talk to the outside world (your frontend, your indexer, The Graph) — they cost gas, get written into transaction logs, and are filterable by indexed parameters. And every external function takes its inputs through ABI encoding, not stdin — so the playground exposes a typed Args panel that wires straight into your main(...) parameters.

What this Solidity playground does well

  • Real solc + EVM execution, not a transpiler simulation. console.log uses forge-std and the emit / storage paths go through actual EVM semantics — opcodes, gas, all of it.
  • Events tab shows every emit from your run with indexed parameters flagged distinctly, so you can see exactly what a frontend or subgraph would receive.
  • Storage tab shows the final value of every state variable the contract touched — including mapping entries (e.g. balances[0xabc...]). Variables you didn't write don't appear.
  • Typed Args panel feeds values to a parametric main(uint256 n, string memory name, ...). The runner ABI-encodes them based on your function's signature, so 42 becomes a uint256 and "hello" becomes a string.

What you can build in the Solidity playground

  • Counter / increment-decrement contracts to learn how state variables persist across calls — write to count, run, then watch it appear in the Storage tab.
  • Token-flow patterns — emit Transfer(from indexed, to indexed, value) and see indexed vs non-indexed fields rendered differently in the Events tab, the same way they appear in real EVM log topics.
  • require / revert failure cases — write a guard that fails on bad input and see the revert message surface in stdout, instead of burning gas on a failed transaction on mainnet.

Frequently asked questions about Solidity

What is Solidity?
Solidity is the most widely-used smart-contract language for Ethereum and EVM-compatible chains (Polygon, Arbitrum, Optimism, Base, etc.). It compiles to EVM bytecode — a stack-machine instruction set executed by every node on the network. Syntactically it borrows from JavaScript and C++, but the semantics are very different: storage is expensive and permanent, every call is metered in gas, and there's no async. The playground gives you a sandboxed EVM so you can practice the language without touching a real chain.
Do I need a wallet or testnet ETH to use this?
No. The playground runs your contract inside a server-side EVM (the same engine geth ships with) in an isolated container per request. There's no on-chain transaction, no gas paid in real ETH, no wallet signature. When you press Run, the runner deploys your contract to a fresh in-memory chain, calls your main(...) function with whatever args you supplied, and shows you stdout, events, and storage from that one call. Everything is thrown away after the Run.
How do I pass inputs to my contract?
Give your contract a function called main(...) with whatever typed parameters you want — function main(uint256 n) external or function main(string memory name, uint256 age, bool active) external view. Then add the values in the Args panel below the editor. The runner inspects the function's signature and ABI-encodes your strings into the right types, the same way cast call does on the command line. For an address argument, type 0x...; for a bool, type true or false; for a uint, type the decimal value.
What's the difference between the Output, Events, and Storage tabs?
Output shows whatever you wrote to stdout via console.log(...) from forge-std/console.sol, plus any revert / require error message. Events shows every event your contract emitted during the run, in order, with each parameter's value (and a small "indexed" pill for indexed params — those are the ones that go into EVM log topics and are filterable by tools like The Graph). Storage shows the post-run value of every state variable that got written, including individual mapping entries — variables you didn't touch stay out of the list.
Why is there no main() in some Solidity tutorials I've read?
On a real chain, Solidity contracts don't have a single entry point — clients call whatever public function they want, identified by its 4-byte selector. The playground uses main() as a convention so there's an obvious thing to run and a place to put arguments. Outside the playground, your contract will typically expose multiple functions (mint, transfer, withdraw, ...) and your frontend or a tool like cast / ethers / viem picks which one to call.