.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.

What opens 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.

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

Open a .sol file step by step

  1. Confirm the file really is a .sol. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
  2. On Windows, open it with VS Code (Solidity extension) or Remix IDE (browser).
  3. On Mac, use VS Code (Solidity extension) or Remix IDE (browser).
  4. On Linux, try VS Code (Solidity extension) or Remix IDE (browser).
  5. Still stuck? Convert the .sol to EVM bytecode, which opens more widely.

Why can't I open my .sol file?

Almost always because no installed app understands Solidity. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.

The other possibility is that the file is not really a .sol at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.

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.

Solidity has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.

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. How sources are ranked and what is deliberately left out is set out in the methodology.