Solidity

Solidity is an object-oriented, high-level language for implementing smart contracts on the Ethereum blockchain and other compatible platforms.

Solidity is designed to target the Ethereum Virtual Machine (EVM). It is statically typed, supports inheritance, libraries, and complex user-defined types. Developers use Solidity to write smart contracts that govern the behavior of accounts and applications on the blockchain. The language's syntax is similar to JavaScript and C++, making it relatively accessible to programmers familiar with these languages. Solidity code is compiled into bytecode, which is then deployed and executed on the EVM.

Solidity's features include support for state variables, functions, events, and modifiers. It also provides built-in cryptographic functions and access to blockchain data. However, Solidity smart contracts are immutable once deployed, so careful planning and thorough testing are crucial to avoid vulnerabilities. Security audits and formal verification are common practices to mitigate risks.

        graph LR
  Center["Solidity"]:::main
  Pre_javascript["javascript"]:::pre --> Center
  click Pre_javascript "/terms/javascript"
  Pre_smart_contract["smart-contract"]:::pre --> Center
  click Pre_smart_contract "/terms/smart-contract"
  Rel_ethereum["ethereum"]:::related -.-> Center
  click Rel_ethereum "/terms/ethereum"
  Rel_smart_contract_architecture["smart-contract-architecture"]:::related -.-> Center
  click Rel_smart_contract_architecture "/terms/smart-contract-architecture"
  Rel_java["java"]:::related -.-> Center
  click Rel_java "/terms/java"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧠 Knowledge Check

1 / 1

🧒 Explain Like I'm 5

📜 Solidity is a special code language used to write 'digital rules' for the world's computer ([Ethereum](/en/terms/ethereum)). It's like writing a contract that nobody can cheat on because the computer follows the rules exactly as they are written.

🤓 Expert Deep Dive

Solidity's design prioritizes deterministic execution within the EVM, crucial for consensus. Its static typing catches many errors at compile time, reducing runtime surprises. The language's object-oriented features, while convenient, introduce complexities in inheritance and state management that can lead to subtle bugs if not managed carefully. Gas optimization is a primary concern; inefficient Solidity code can lead to prohibitively expensive transactions. The compiler itself is a critical component, and its evolution (e.g., introduction of Yul IR, optimizer improvements) significantly impacts gas costs and security. [Formal verification tools](/en/terms/formal-verification-tools) are increasingly important for auditing Solidity contracts due to the high stakes of immutable, on-chain logic.

🔗 Related Terms

Prerequisites:

📚 Sources