.sol

What is a .sol file?

Solidity Smart Contract Source File · Code and data · Ethereum Foundation · 2014

A .sol file is Solidity source code, the main language for smart contracts on Ethereum and compatible blockchains. The compiled contract runs on the Ethereum Virtual Machine and can control real funds.

Category
Code and data
MIME type
Type
Plain text
Is a .sol file safe to open? Caution. A .sol file is source code for contracts that can move funds once deployed. Reading it is safe; deploying or interacting with unaudited contracts is the real risk.

What is a .sol file used for?

Solidity looks like a blend of JavaScript and C++, but the stakes are unusual: deployed contract code is public, effectively immutable, and often guards money, so small bugs have caused famous multi-million losses.

That is why Solidity work leans heavily on audits, tests and frameworks such as Hardhat and Foundry. The files are plain text and open in any editor; the browser-based Remix IDE is the common playground.

How to open a .sol file

The .sol format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .sol file.

Windows

  • VS Code (Solidity extension)
  • Remix IDE (browser)
  • any text editor

macOS

  • VS Code (Solidity extension)
  • Remix IDE (browser)
  • any text editor

Linux

  • VS Code (Solidity extension)
  • Remix IDE (browser)
  • any text editor

How to convert a .sol file

You can convert a .sol file to EVM bytecode, abi (JSON) using a conversion tool or the export menu of an app that opens it.

.sol file signature (magic bytes)

Programs recognise a .sol file by the bytes at the start of the file, not by its name. These are the signatures for Solidity.

Hex signatureOffsetNote
(no fixed signature)0plain text; no fixed magic bytes

See the full magic-numbers reference for every format.

Frequently asked questions

What is a .sol file?

A .sol file is Solidity source code, the main language for smart contracts on Ethereum and compatible blockchains. The compiled contract runs on the Ethereum Virtual Machine and can control real funds.

How do I open a .sol file?

Any text editor shows the source. To compile and test it, use the Remix IDE in a browser or a framework such as Hardhat or Foundry.

What does a .sol file become when compiled?

EVM bytecode plus an ABI (a JSON description of the contract's functions). The bytecode is deployed to the blockchain; apps use the ABI to call it.

Why are Solidity bugs so serious?

Deployed contracts are public and effectively immutable, and often hold funds. A logic flaw cannot be quietly patched, which is why audits are standard practice.

Related formats

Sources

Details on this page were checked against authoritative references: