https://github.com/solidstate-network/hardhat-license-identifier
©️ Prepend local Solidity source files with an SPDX License Identifier 🔨
https://github.com/solidstate-network/hardhat-license-identifier
blockchain buidler ethereum hardhat solc solidity spdx-license spdx-licenses wow
Last synced: 17 days ago
JSON representation
©️ Prepend local Solidity source files with an SPDX License Identifier 🔨
- Host: GitHub
- URL: https://github.com/solidstate-network/hardhat-license-identifier
- Owner: solidstate-network
- License: mit
- Created: 2020-05-18T01:30:46.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-09-18T18:10:46.000Z (6 months ago)
- Last Synced: 2025-10-21T21:11:07.791Z (5 months ago)
- Topics: blockchain, buidler, ethereum, hardhat, solc, solidity, spdx-license, spdx-licenses, wow
- Language: TypeScript
- Homepage:
- Size: 401 KB
- Stars: 23
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Hardhat License Identifier
Automatically prepend Solidity source files in Hardhat projects with an SPDX License Identifier.
> Versions of this plugin prior to `3.0.0` were released as `hardhat-spdx-license-identifier`, outside of the `@solidstate` namespace.
> Versions of this plugin prior to `2.0.0` were released as `buidler-spdx-license-identifier`.
## Installation
```bash
npm install --save-dev @solidstate/hardhat-license-identifier
# or
pnpm add -D @solidstate/hardhat-license-identifier
```
## Usage
Load plugin in Hardhat config:
```javascript
import hardhatLicenseIdentifier from '@solidstate/hardhat-license-identifier';
const config: HardhatUserConfig = {
plugins: [
hardhatLicenseIdentifier,
],
licenseIdentifier: {
... // see table for configuration options
},
};
```
Add configuration under the `licenseIdentifier` key:
| option | description | default |
| -------------- | ------------------------------------------------------------------------------------------------------ | --------------------------------- |
| `license` | SPDX license to add to source files | `license` field of `package.json` |
| `overwrite` | whether to overwrite existing SPDX license identifiers | `false` |
| `runOnCompile` | whether to automatically prepend identifiers during compilation | `false` |
| `only` | `Array` of `String` matchers used to select included paths, defaults to all contracts if `length` is 0 | `[]` |
| `except` | `Array` of `String` matchers used to exclude paths | `[]` |
```javascript
licenseIdentifier: {
overwrite: true,
runOnCompile: true,
except: ['vendor/']
}
```
The included Hardhat task may be run manually. Its arguments override any existing configuration:
```bash
npx hardhat prepend-license UNLICENSED --overwrite
# or
pnpm hardhat prepend-license UNLICENSED --overwrite
```
Files which do not contain a license identifier will be prepended with one. Files with a license identifier which does not match that which is specified in `package.json` may be updated, depending on configuration.
## Development
Install dependencies via pnpm:
```bash
pnpm install
```
Setup Husky to format code on commit:
```bash
pnpm prepare
```