Solidity
v0.8.34
Solidity
v0.8.34
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.
// 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";
}
}Yes. CompileBytes compiles your Solidity source in the browser, so you don't need to install the solc compiler or any blockchain tooling locally.
The compiler version reported is 0.8.34, part of the 0.8.x series with built-in overflow/underflow checks and custom errors.
The online environment compiles and runs/checks your contract code, but deploying to Ethereum mainnet or a testnet requires a wallet, gas, and a network connection through tools like Remix, Hardhat, or Foundry.
Solidity emits a warning without an SPDX license identifier, and the pragma line pins the compiler version so your contract compiles with a compatible toolchain.
Yes, compiling Solidity on CompileBytes is completely free.