Solidity Source File Layout

In Solidity, source files have the .sol extension and serve as the foundational building blocks for smart contracts on the Ethereum blockchain. These files can include a wide array of elements essential for contract development and deployment. Specifically, source files can contain any number of contract definitions, import, pragma, and using for directives. They can also include definitions for data structures like struct and enum, as well as function, error, and constant variables.

SPDX license identifier

The Solidity compiler encourages the use of machine-readable SPDX licensing IDs because the availability of source code always raises issues of copyright law. Every source file has to have a statement at the top stating its license.

Get hands-on with 1400+ tech skills courses.