0
0
Blockchain / Solidityprogramming~10 mins

SPDX license and pragma version in Blockchain / Solidity - Mini Project: Build & Apply

Choose your learning style9 modes available
SPDX License and Pragma Version in Solidity
📖 Scenario: You are creating a simple smart contract for a blockchain project. To make your code clear and compatible with tools, you need to add a license identifier and specify the Solidity compiler version.
🎯 Goal: Learn how to add the SPDX license identifier and the pragma version statement at the top of a Solidity contract.
📋 What You'll Learn
Add the SPDX license identifier comment at the top of the file
Add the pragma solidity version statement below the license
Use the exact license identifier MIT
Use the exact pragma version ^0.8.0
💡 Why This Matters
🌍 Real World
Adding SPDX license identifiers and pragma versions is a standard practice in Solidity smart contract development to ensure legal clarity and compiler compatibility.
💼 Career
Understanding these basics is essential for blockchain developers to write professional and maintainable smart contracts.
Progress0 / 4 steps
1
Add SPDX License Identifier
Add the SPDX license identifier comment // SPDX-License-Identifier: MIT as the very first line of your Solidity file.
Blockchain / Solidity
Need a hint?
The SPDX license identifier is a comment that starts with // SPDX-License-Identifier: followed by the license name.
2
Add Pragma Solidity Version
Below the SPDX license identifier, add the pragma solidity version statement pragma solidity ^0.8.0; to specify the compiler version.
Blockchain / Solidity
Need a hint?
The pragma statement tells the compiler which Solidity versions are allowed.
3
Create a Simple Contract
Create a simple contract named MyContract below the pragma statement using contract MyContract { }.
Blockchain / Solidity
Need a hint?
A contract is defined using the keyword contract followed by its name and curly braces.
4
Output the Contract Code
Print the entire contract code as a string using console.log in JavaScript or just display the code as output. For this exercise, just print the SPDX line, pragma line, and contract declaration exactly as written.
Blockchain / Solidity
Need a hint?
Use a print statement to show the full contract code exactly as it appears.