SPDX license identifier not provided in source file

Hi guys could someone point me in the right direction. I’m trying to truffle test and it’s saying SPDX identifier not provided in source file. I’m not sure what this is. My error is:

Compiling your contracts...
===========================
> Compiling .\contracts\dex.sol
> Compilation warnings encountered:

    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.
--> /C/Users/dell/OneDrive/DEX/contracts/dex.sol

,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.
--> /C/Users/dell/OneDrive/DEX/contracts/wallet.sol


> Artifacts written to C:\Users\dell\AppData\Local\Temp\test--7332-aMy2YOxl4AkZ> Compiled successfully using:
   - solc: 0.8.4+commit.c7e474f2.Emscripten.clang

Error: Returned values aren't valid, did it run Out of Gas? You might also see 
this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
    at module.exports (C:\Users\dell\OneDrive\DEX\migrations\3_token_migration.js:11:36)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)        
    at Migration._deploy (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:79:1)
    at Migration._load (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:61:1)
    at Migration.run (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:212:1)
    at Object.runMigrations (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:150:1)
    at Object.runFrom (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:110:1)
    at Object.runAll (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:114:1)
    at Object.run (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:79:1)
    at Object.run (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\testing\Test.js:109:1)
    at Object.run (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\test\index.js:165:1)
    at Command.run (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\command.js:140:1)

The error appears to be in the dex.sol contract which is as follows:

pragma solidity 0.8.4;
pragma experimental ABIEncoderV2;

import "./wallet.sol";

contract Dex is Wallet {

    enum Side {
        BUY,
        SELL
    }

    struct Order {
        uint id;
        address trader;
        bool buyOrder;
        bytes32 ticker;
        uint amount;
        uint price;
    }

    mapping(bytes32 => mapping(uint => Order[])) public orderBook;

    function getOrderBook(bytes32 ticker, Side side) view public returns(Order[] memory){
        return orderBook[ticker][uint(side)];
   }

    // function createLimitOrder() {
        
    // }
}

Any help would be much appreciated. Thanks

1 Like

To avoid this, you have to specify the SPDX identifier.

just add this code line to your contracts and it should disappear.

// SPDX-License-Identifier: <SPDX-License>

Carlos Z

1 Like