5/5
## Declaring a Software License in Your Vyper Smart Contract When writing a Vyper smart contract, after specifying the compiler version using the `pragma` directive, it's a crucial best practice to declare the software license under which your code is released. This is typically done on the very next line using a specific comment format. For instance, if your contract starts with: ```vyper # pragma version 0.4.0 ``` You would immediately follow it by adding a license identifier, like this: ```vyper # pragma version 0.4.0 # @license MIT ``` This `# @license MIT` line serves several important functions: 1. **Informs the Community:** It clearly communicates to other developers, users, and potential auditors the terms under which they can use, modify, and distribute your code. 2. **Informs the Compiler:** Vyper compilers often look for this identifier. Including it can prevent warnings or errors during the compilation process, ensuring smoother development. While many different software licenses exist (you can explore approved open-source licenses via the Open Source Initiative - OSI), the `MIT` license is extremely common in the smart contract and blockchain space. Much of the development in this ecosystem embraces open-source principles. Seeing `# @license MIT` signals that the code is open source. The MIT license is one of the most **permissive** licenses available. It essentially grants broad permissions to anyone, allowing them to: * Use the software freely. * Copy and distribute the software. * Modify and merge the software. * Publish, sublicense, and even sell copies of the software or derivative works. For simple or foundational smart contracts, like those often created during learning, a permissive license like MIT is usually appropriate, as the goal is often transparency and reusability rather than restriction. **Why is explicitly declaring a license so important?** * **Legal Clarity:** If code does *not* have an explicit license, it defaults to being **unlicensed**. This generally means it is proprietary, and all rights are reserved by the author. Explicitly stating the license avoids ambiguity and clarifies the legal standing of your code. * **Avoiding Compiler Issues:** As mentioned, compilers often expect a license identifier. Adding it proactively satisfies this requirement. * **Aligning with Open Source Norms:** In the Web3 world, transparency and collaboration are highly valued. Using a standard open-source license identifier aligns your project with these community expectations. Therefore, while a deep dive into software licensing isn't necessary to get started, recognizing the `# @license <IDENTIFIER>` pattern and understanding its purpose is vital. Including it, especially a common one like `MIT` for open-source work, is a standard and recommended practice for Vyper development.
An essential overview to Declaring a Software License in Your Vyper Smart Contract - Learn why and how to declare a software license using `# @license <IDENTIFIER>` right after your pragma directive in Vyper. Understand the significance for legal clarity, compiler warnings, and embracing open-source principles with licenses like MIT.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
The basics of blockchain transactions, how to send and receive money on a blockchain network.
How to write Python based smart contracts using Vyper.
How to read and understand Vyper smart contracts.
Vyper data structures, arrays, structs, hash maps.
How to build a smart contract application and deploy on ZKsync with Moccasin.
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on June 11, 2025
Duration: 2h 08min
Duration: 2h 32min
Duration: 24min
Course Overview
About the course
The basics of blockchain transactions, how to send and receive money on a blockchain network.
How to write Python based smart contracts using Vyper.
How to read and understand Vyper smart contracts.
Vyper data structures, arrays, structs, hash maps.
How to build a smart contract application and deploy on ZKsync with Moccasin.
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on June 11, 2025