A Language Built for the Blockchain
Solidity is a high-level, statically typed programming language designed specifically to write smart contracts that execute on the Ethereum Virtual Machine (EVM). Unlike general-purpose languages such as Python or Java, Solidity is contract-oriented: its core building block is the contract, a bundle of state variables and functions that lives at an address on the blockchain. It borrows curly-brace syntax and influences from JavaScript, C++, and Python, which makes it approachable, but every design decision serves the constraints of a decentralized, deterministic execution environment where code is public and effectively immutable once deployed.
Cricket analogy: Just as the LBW law only makes sense inside cricket's rulebook and would be meaningless in football, Solidity's design only makes sense inside the EVM's deterministic rulebook rather than a general computing environment.
Smart Contracts and the EVM
A smart contract is a program stored on the blockchain that runs exactly as written whenever it is called, with no possibility of downtime, censorship, or third-party interference. When you write Solidity, the compiler translates your source into EVM bytecode, a low-level stack-based instruction set. Every operation costs gas, a unit of computational effort paid for in ether, which discourages infinite loops and prices resource usage. Because thousands of independent nodes re-execute the same bytecode to reach consensus, execution must be fully deterministic: there is no random number generator, no network access, and no system clock beyond block-level timestamps.
Cricket analogy: Just as a run-out is decided the same way whether reviewed by the on-field umpire or the third umpire, EVM bytecode must produce the same result on every node re-executing it.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// A minimal contract that stores and returns a greeting
contract HelloWorld {
string public greeting = "Hello, Blockchain!";
function setGreeting(string calldata newGreeting) external {
greeting = newGreeting;
}
}The // SPDX-License-Identifier comment and the pragma solidity version directive are conventional at the top of every file. The pragma tells the compiler which language version the code targets, guarding against breaking changes between compiler releases.
Why Immutability Changes How You Code
Once a contract is deployed to a live network, its code cannot be edited or patched in place; the bytecode at that address is permanent. This immutability is a feature that guarantees users the rules will not change under them, but it also means bugs are permanent and often exploitable for real money. High-profile losses such as the 2016 DAO hack, which drained roughly 3.6 million ether through a reentrancy flaw, show why Solidity development emphasizes rigorous testing, formal audits, and defensive patterns before deployment. Upgradeability, when needed, is achieved indirectly through proxy patterns rather than by modifying deployed code.
Cricket analogy: Just as an umpire's on-field decision once the DRS reviews are exhausted stands permanently for that ball, deployed contract code stands permanently and cannot be recalled.
Never treat a deployed contract as a draft you can fix later. Because bugs are permanent and funds are at stake, always test on a local network and a public testnet, and consider a professional audit before mainnet deployment.
- Solidity is a statically typed, contract-oriented language purpose-built for the Ethereum Virtual Machine.
- Its core unit is the contract, which bundles persistent state variables and callable functions at a blockchain address.
- The compiler turns Solidity into EVM bytecode, and every operation costs gas paid in ether.
- Execution must be deterministic, so there is no true randomness, no network calls, and no real-time clock.
- Deployed code is immutable, making thorough testing and audits essential before going live.
- Upgradeability is handled via proxy patterns rather than editing deployed bytecode.
Practice what you learned
1. What is the primary execution environment that Solidity targets?
2. Why can't a Solidity contract use a normal random number generator?
3. What does 'gas' represent in the EVM?
4. What is a key consequence of contract immutability?
5. How is upgradeability typically achieved for smart contracts?
Was this page helpful?
You May Also Like
Setting Up Remix and Hardhat
Learn the two most common Solidity development environments: the browser-based Remix IDE for quick experiments and the Node.js-based Hardhat framework for professional project workflows.
Solidity Syntax and Variables
Understand Solidity's file structure, the difference between state, local, and global variables, and how visibility and data location affect where values live and who can read them.
Your First Smart Contract
Write, compile, and deploy a complete storage contract, learning about the constructor, functions, events, access control, and the payable keyword along the way.
Related Reading
Related Study Notes in Programming
Browse all study notesApache Spark Study Notes
Programming · 30 topics
ProgrammingApache Flink Study Notes
Programming · 30 topics
ProgrammingHadoop Study Notes
Programming · 30 topics
ProgrammingSnowflake Study Notes
Programming · 30 topics
ProgrammingApache Airflow Study Notes
Programming · 30 topics
Programmingdbt (Data Build Tool) Study Notes
Programming · 30 topics