# Solidity — Smart Contract Language for Ethereum and EVM Chains > Solidity is a statically-typed, contract-oriented language designed for writing smart contracts on the Ethereum Virtual Machine and compatible blockchains. ## Install Save as a script file and run: # Solidity — Smart Contract Language for Ethereum and EVM Chains ## Quick Use ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Counter { uint256 public count; function increment() public { count += 1; } } ``` ```bash # Compile with solc npm install -g solc solcjs --bin --abi Counter.sol ``` ## Introduction Solidity is the primary programming language for Ethereum smart contracts. It compiles to EVM bytecode and runs on Ethereum, Polygon, Arbitrum, Optimism, BNB Chain, and any EVM-compatible network. Its syntax draws from C++, Python, and JavaScript. ## What Solidity Does - Defines smart contracts with state variables, functions, and events - Compiles to EVM bytecode for on-chain deployment - Supports inheritance, libraries, and user-defined types - Provides built-in primitives for cryptographic operations and address handling - Enforces gas-aware execution constraints at the language level ## Architecture Overview The Solidity compiler (solc) parses source code into an AST, applies type checking and optimization passes, then emits EVM bytecode and ABI metadata. An intermediate representation called Yul enables low-level optimization. The compiler also generates source maps for debugger integration. ## Self-Hosting & Configuration - Install the compiler via npm (`solc`), Homebrew, or static binaries - Use Hardhat or Foundry for project scaffolding, testing, and deployment - Configure compiler version and optimization in `hardhat.config.js` or `foundry.toml` - Enable the optimizer with `--optimize` and set runs for deployment vs. call frequency tradeoffs - Pin the pragma version to avoid unexpected behavior across compiler updates ## Key Features - Mature type system with value types, reference types, and mappings - Modifier and inheritance patterns enable access control and code reuse - NatSpec comments generate human-readable documentation from source - Built-in overflow checks since v0.8.0 eliminate a common vulnerability class - Custom errors reduce gas cost compared to revert strings ## Comparison with Similar Tools - **Vyper** — Python-like syntax with a smaller feature set; prioritizes auditability over flexibility - **Huff** — Low-level EVM assembly language for gas-optimized contracts; no high-level abstractions - **Fe** — Rust-inspired EVM language; early stage with a focus on safety - **Move** — Used on Aptos and Sui; resource-oriented model, not EVM-compatible ## FAQ **Q: What is the current stable Solidity version?** A: Check the official releases page; the project follows semantic versioning with frequent minor releases. **Q: How do I prevent reentrancy attacks?** A: Use the checks-effects-interactions pattern or OpenZeppelin's ReentrancyGuard modifier. **Q: Can Solidity contracts call off-chain APIs?** A: Not directly. Contracts use oracles like Chainlink to bring external data on-chain. **Q: Is Solidity Turing-complete?** A: Yes, but execution is bounded by the gas limit, preventing infinite loops in practice. ## Sources - https://github.com/ethereum/solidity - https://docs.soliditylang.org/ --- Source: https://tokrepo.com/en/workflows/asset-800a0ac1 Author: Script Depot