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

652 Views Asked by At
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

1

There are 1 best solutions below

0
Petr Hejda On BEST ANSWER

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 {