Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: SPDX license identifier not provided in source file

Tags:

I created a new solidity contract. The contract is up and running but giving me this warning.

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

There are no errors while compilation.

The Compiler version I am using in https://remix.ethereum.org/ is v0.7.5+commit.eb77ed08 Language: Solidity EVM VERSION: compiler default

Whenever I press compile it gives me the warning but there is no problem while deploying.

My code snippet:

pragma solidity ^0.7.5; contract TestContract { // Some logic }   
like image 430
Gogle Gogle Avatar asked Dec 10 '20 12:12

Gogle Gogle


People also ask

What is Spdx license identifier in solidity?

Solidity 0.6. 8 introduces SPDX license identifiers so developers can specify the license the contract uses. (e.g. OpenZeppelin Contracts use MIT license). SPDX license identifiers should be added to the top of contract files. (

How do I install Spdx license?

You can start by adding SPDX LIDs to new files without changing anything already present in your codebase. A list of projects known to be using SPDX License Identifiers can be found at: https://spdx.org/ids-where, and if you know of one that's missing, please send email to [email protected].


1 Answers

From Solidity ^0.6.8 SPDX license is introduced. So you need to use SPDX-License-Identifier in the code.

Have a look at this: https://forum.openzeppelin.com/t/solidity-0-6-8-introduces-spdx-license-identifiers/2859

For example in your code you need to use license identifier like

// SPDX-License-Identifier: MIT pragma solidity ^0.7.5; contract TestContract { // Some logic } 

You need to use license according to your project. Some other licenses are:

// SPDX-License-Identifier: GPL-3.0-or-later 

You can find list of licenses here: https://spdx.org/licenses/

like image 55
Gribesh Dhakal Avatar answered Sep 29 '22 12:09

Gribesh Dhakal