logoJourney BlogAffiliate links are used in this blog to earn income
WrappedUsername

WrappedUsername

Jul 31, 2022

Solidity Style Guide

Solidity style guide

Order of Layout

Layout contract elements in the following order:

	1.	Pragma statements
	2.	Import statements
	3.	Interfaces
	4.	Libraries
	5.	Contracts

Inside each contract, library or interface, use the following order:

	1.	Type declarations
	2.	State variables
	3.	Events
	4.	Modifiers
	5.	Functions

Order of Functions

Ordering helps readers identify which functions they can call and to find the constructor and fallback definitions easier.

Functions should be grouped according to their visibility and ordered:

	•	constructor
	•	receive function (if exists)
	•	fallback function (if exists)
	•	external
	•	public
	•	internal
	•	private

Within a grouping, place the view and pure functions last.

NatSpec Format

For Solidity you may choose:

/// for single line comments, or for multi-line comments /** ending with */. /// @title Should describe the contract/interface i.e. /// @title A simple NFT project /// @author The name of the author i.e. /// @author WrappedUsername /// @notice Explains to end user what the object does i.e. /// @notice Transfers NFT from one account to the other /// @dev Explains to a developer any extra details i.e. /** @dev All function calls are currently implemented without known side effects, but this may change after further testing/audit process. */

image.png

In Conclusion

  • Are you currently looking for a web3 blockchain job or other dev jobs? Check this out! Developer Jobs Here!
WrappedUsername

WrappedUsername

I am a self taught Solidity Smart Contract Auditor. Creator of this blog site.

Leave a Reply

Related Posts

background image

🎉 Thank you! 🎉

Our sponsor Foam Chunk Smudge NFT, an abstract art project, has created a token pass utility for this NFT. The Foam Chunk Smudge NFT token HODLer community on Discord has access to private channels with special vip only announcements, and much more! Check them out!

Our Sponsor

Categories

logoJourney Blog

© 2023 Journey Blog. All rights reserved.