Minimal contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.34;
contract HelloWorld {
string public greeting = "Hello, World!";
}Tap Run to execute
main.sol · output appears here
Press Run to execute
Output streams here as your program runs.
Solidity is a statically typed, contract-oriented language for writing smart contracts that run on the Ethereum Virtual Machine (EVM) and other EVM-compatible blockchains. Its syntax is influenced by C++, Python, and JavaScript, and it supports inheritance, libraries, user-defined types, and complex member variables. Contracts compiled to EVM bytecode are deployed on-chain and execute deterministically across every node in the network.
CompileBytes uses Solidity compiler version 0.8.34. The 0.8.x series introduced built-in checked arithmetic that reverts on overflow and underflow by default, along with custom errors and other safety improvements. The online environment is ideal for learning syntax, experimenting with contract structure, and checking that code compiles, though deploying and calling live contracts requires a blockchain network or a local EVM such as Hardhat or Foundry.
main.sol is the entry point for each run.
Use the Input panel to pipe standard input to your program when it needs data.
Run sends your code to a fresh hosted runtime and streams the result into the output panel.
Your draft stays in this browser, and Share creates a separate snapshot link.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.34;
contract HelloWorld {
string public greeting = "Hello, World!";
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.34;
contract Counter {
uint256 public count;
function increment() public {
count += 1;
}
function get() public view returns (uint256) {
return count;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.34;
contract Balances {
mapping(address => uint256) public balanceOf;
event Deposited(address indexed who, uint256 amount);
function deposit() public payable {
balanceOf[msg.sender] += msg.value;
emit Deposited(msg.sender, msg.value);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.34;
contract Math {
function sum(uint256 n) public pure returns (uint256 total) {
for (uint256 i = 1; i <= n; i++) {
total += i;
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.34;
contract Owned {
address public owner;
constructor() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner, "not owner");
_;
}
function rescue() public view onlyOwner returns (bool) {
return true;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.34;
contract Vault {
mapping(address => uint256) public balance;
error InsufficientBalance(uint256 requested, uint256 available);
function withdraw(uint256 amount) public {
uint256 bal = balance[msg.sender];
if (amount > bal) {
revert InsufficientBalance(amount, bal);
}
balance[msg.sender] = bal - amount;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.34;
contract Registry {
struct Item {
string name;
uint256 value;
}
Item[] public items;
function add(string calldata name, uint256 value) public {
items.push(Item(name, value));
}
function count() public view returns (uint256) {
return items.length;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.34;
contract Light {
enum State { Red, Green }
State public state = State.Red;
function toggle() public {
if (state == State.Red) {
state = State.Green;
} else {
state = State.Red;
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.34;
contract Base {
function name() public pure virtual returns (string memory) {
return "base";
}
}
contract Derived is Base {
function name() public pure override returns (string memory) {
return "derived";
}
}The editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.
Type or paste your code into the editor, then click Run (or press Ctrl/Cmd + Enter) to execute it.
Output streams into the console panel, including runtime errors, exit status, and execution time.
Nothing to install and no account to create — code runs in an isolated hosted runtime.
Language-aware autocomplete and IntelliSense suggestions where the editor has a matching language service
Syntax highlighting, with native compiler and runtime errors shown in the console
Bracket matching, auto-indentation, code folding, and a minimap
Multi-cursor editing plus find & replace (Ctrl/Cmd + F)
Full undo/redo history and copy to clipboard
Built on Monaco — the same editor that powers VS Code
Run on demand, or turn on Auto-run to execute on every change
Stop long-running or infinite programs at any time
A real console shows standard output, errors, exit status, and execution time
Pass standard input (stdin) to your program from the Input panel — one value per line
Switch between light and dark themes
Adjust font size and other editor settings
Toggle side-by-side or top/bottom layouts
Enter distraction-free fullscreen mode
Generate a shareable link to your exact code in one click — no login needed
Your work autosaves to your browser, so you can pick up where you left off
Copy the active file to your clipboard
Run code: Ctrl/Cmd + Enter
Find & replace: Ctrl/Cmd + F
Open the full shortcut list from the keyboard icon in the toolbar
Solidity is one of 46 single-file compiler scratchpads. Each run submits only main.sol; local sibling-file imports are not enabled.
Linked-project languages (23): Node.js, TypeScript, Deno, Python, C, Go, Dart, Swift, Rust, Ruby, PHP, Java, Kotlin, C++, C#, Nim, Crystal, Haxe, Zig, Scala, D, Bun, Objective-C.
Single-file scratchpads (46): Matplotlib, NumPy, pandas, Haskell, Clojure, Perl, Lua, Tcl, jq, Raku, Elixir, Bash, Zsh, Nushell, R, Assembly (NASM), Julia, Octave, Groovy, PowerShell, Visual Basic .NET, Odin, Pascal, Lisp, Erlang, CoffeeScript, COBOL, BASIC, V, Racket, OCaml, Prolog, AWK, Emacs Lisp, Emojicode, Forth, F#, Fortran, Assembly (NASM64), Solidity, Mojo, Ada, WASM (WAT), Gleam, Shell Script (sh), Scheme.
Download file exports the active Solidity source file.