hardhat-web3sentinel
v1.0.0
Published
Hardhat plugin for Web3Sentinel smart contract security audits
Maintainers
Readme
hardhat-web3sentinel
Hardhat plugin for Web3Sentinel smart contract security audits.
What is Web3Sentinel?
Web3Sentinel is an AI-powered smart contract security platform that provides instant, affordable security audits. This Hardhat plugin integrates Web3Sentinel directly into your development workflow.
Installation
npm install --save-dev hardhat-web3sentinelSetup
1. Import the plugin in your hardhat.config.js:
require("hardhat-web3sentinel");
module.exports = {
solidity: "0.8.19",
web3sentinel: {
apiKey: process.env.WEB3SENTINEL_API_KEY, // or hardcode (not recommended)
failOnCritical: true, // Fail build if critical vulnerabilities found
failOnHigh: false, // Fail build if high severity vulnerabilities found
minSecurityScore: 70 // Minimum security score required
}
};2. Get your API key
- Sign up at web3sentinel.org
- Go to Dashboard → API Keys
- Create a new API key
- Set it as environment variable:
export WEB3SENTINEL_API_KEY=ws_your_api_key_hereUsage
Audit all contracts
npx hardhat auditAudit specific contract
npx hardhat audit --contract MyToken.solAudit all contracts explicitly
npx hardhat audit --allConfiguration Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| apiKey | string | - | Your Web3Sentinel API key (required) |
| failOnCritical | boolean | true | Fail build if critical vulnerabilities found |
| failOnHigh | boolean | false | Fail build if high severity vulnerabilities found |
| minSecurityScore | number | 70 | Minimum security score (0-100) required to pass |
Example Output
🔍 Web3Sentinel Smart Contract Audit
Found 2 contract(s) to audit
📄 Auditing: MyToken.sol
Status: completed
✅ Audit complete
Security Score: 85/100
Gas Score: 78/100
Vulnerabilities: 2
📄 Auditing: MyNFT.sol
Status: completed
✅ Audit complete
Security Score: 92/100
Gas Score: 88/100
Vulnerabilities: 0
📊 Audit Summary
🟢 MyToken: 85/100 (2 issues)
🟢 MyNFT: 92/100 (0 issues)
✅ All audits passed!CI/CD Integration
GitHub Actions
name: Security Audit
on: [push, pull_request]
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: npm install
- run: npx hardhat audit
env:
WEB3SENTINEL_API_KEY: ${{ secrets.WEB3SENTINEL_API_KEY }}GitLab CI
audit:
stage: test
script:
- npm install
- npx hardhat audit
variables:
WEB3SENTINEL_API_KEY: $WEB3SENTINEL_API_KEYPre-deployment Hook
Add to your deployment script:
// scripts/deploy.js
const hre = require("hardhat");
async function main() {
// Run audit before deployment
console.log("Running security audit...");
await hre.run("audit");
// Deploy contract
const MyContract = await hre.ethers.getContractFactory("MyContract");
const contract = await MyContract.deploy();
await contract.deployed();
console.log("Contract deployed to:", contract.address);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});Programmatic Usage
const { Web3Sentinel } = require("web3sentinel-sdk");
task("custom-audit", "Custom audit task").setAction(async (_, hre) => {
const sentinel = hre.web3sentinel;
const result = await sentinel.audits.submitAndWait({
name: "MyContract",
sourceCode: contractCode
});
console.log("Security Score:", result.securityScore);
});Features
- ✅ Automatic contract discovery
- ✅ AI-powered vulnerability detection
- ✅ Gas optimization analysis
- ✅ Standards compliance checking
- ✅ Configurable failure thresholds
- ✅ CI/CD ready
- ✅ Beautiful terminal output
- ✅ Pre-deployment hooks
Support
- 📧 Email: [email protected]
- 📚 Documentation: https://web3sentinel.org/docs
- 📱 Telegram: @sopdap
- 🐛 Issues: https://github.com/SopeDapo/hardhat-web3sentinel/issues
License
MIT © Web3Sentinel
