3

In hyperledger when @ symbol is used in comments and it has its significance and is required before defining a function. I was going through some solidity code examples and I saw this piece of code

/**
* @title Ownable
* @dev 
*/

so does that @ has any use or significance?

2 Answers 2

4

These are "NatSpec" comments. The Solidity documentation has this to say:

Additionally, there is another type of comment called a natspec comment, for which the documentation is not yet written. They are written with a triple slash (///) or a double asterisk block(/** ... */) and they should be used directly above function declarations or statements. You can use Doxygen-style tags inside these comments to document functions, annotate conditions for formal verification, and provide a confirmation text which is shown to users when they attempt to invoke a function.

The wiki has a bit more about them: https://github.com/ethereum/wiki/wiki/Ethereum-Natural-Specification-Format.

I'm not sure which tools actually consume these comments, but hopefully that documentation will get you started in learning more.

1
2

It's not something that is required before defining a function.

The solidity compiler uses doxygen-style NatSpec tags inside comments to optionally document functions, annotate conditions for formal verification, and provide a confirmation text that is shown to users when they attempt to invoke a function.

The different types of tags are:

  • @title
  • @author
  • @notice
  • @dev
  • @param
  • @return

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.