'How do I add <SPDX-License> as a comment in my code?

pragma solidity >=0.6.0 <0.9.0;

contract SimpleStorage {

    //this will get initialized to 0!
    uint256 favoriteNumber;

    function store(uint256 _favoriteNumber) public {
        favoriteNumber = _favoriteNumber;

        //<SPDX-License>
    }
}

Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. --> SimpleStorage.sol



Solution 1:[1]

The license identifier goes at the first line, before the pragma statement.

Example:

// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.6.0 <0.9.0;

contract SimpleStorage {

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Petr Hejda