Contract names should use CamelCase
Solidity style guide recommends using CamelCase for contract names and ensuring they align with their file names. Improve code readability and conformity with this key tip.
Category
non-critical
Languages
solidity
Analysis Layer
static
Severity
info
According to the Solidity style guide, contract names should be in CamelCase and should match their file names.
In Solidity, it is recommended to follow consistent naming conventions to improve code readability and maintainability. By following the recommended style guide, you can make your code more accessible to other developers and reduce the chances of naming conflicts.
For example, consider the following Solidity contract:
// Filename: myContract.sol
pragma solidity ^0.8.0;
contract myContract {
// Contract implementation goes here
}
In this case, the contract name myContract should be updated to MyContract to adhere to the recommended naming convention. The updated contract would look like this:
// Filename: MyContract.sol
pragma solidity ^0.8.0;
contract MyContract {
// Contract implementation goes here
}
It is important to note that the contract name should match the file name (excluding the file extension). This helps maintain consistency and avoids confusion when working with multiple contracts in the same project.
Following the recommended naming convention also applies to libraries, where the library name should be in CamelCase and match the file name.
By adhering to these conventions, you can enhance the readability of your Solidity code and make it easier for other developers to understand and collaborate on your projects.
Remember to always refer to the official Solidity documentation and style guides for the most up-to-date recommendations.