Yohan.FBK
Yohan.FBK

Reputation: 3

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

Upvotes: 0

Views: 904

Answers (1)

Petr Hejda
Petr Hejda

Reputation: 43581

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 {

Upvotes: 1

Related Questions