
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
solidity-doppelganger
Advanced tools
A tool to check if a contract is similar (exact/fuzzy AST based comparison) to a set of known/common contracts like openzeppelin's
🌐 npm install solidity-doppelganger
A tool to check if a contract is similar to a set of known/common contracts stored in a DB. E.g. quickly check if a contract SafeMath
was copied from a reputable source without having to manually check it.
Allows for strict/exact
and fuzzy
AST based Doppelgänger detection.
// Import
const { SolidityDoppelganger, HASH_MODES } = require('./SolidityDoppelganger');
// Import:
const fs = require("fs");
fs.readFile(fpath, (err, data) => {
if (err) {
console.error(`ERROR processing file '${fpath}': ${err}`);
return;
}
let selectedModes = Array(...new Set(options.modes.split(',').filter(m => HASH_MODES.includes(m))));
let dupeFinder = new SolidityDoppelganger({ modes: selectedModes });
/**
* Optionally hash inputs and print them
* */
dupeFinder.hashSourceCode(data.toString('utf-8'))
.then(results =>
results.forEach(r =>
r.then(x => {
// Result Object
let result = {
name: x.name,
hash: x.hash,
options: x.options,
path: `${fpath}`
};
console.log(JSON.stringify(result));
})
)
);
/**
* Compare sourceCode with database
* */
dupeFinder.compareSourceCode(data.toString('utf-8'), fpath)
.then(results => {
Object.keys(results.results).forEach(contractName => {
// results per contract and path
let resultobj = results.results[contractName];
console.log(`**** MATCH ****: ${resultobj.target.path} :: ${resultobj.target.name}`);
for (let m of resultobj.matches) {
console.log(` :: ${m.name} :: ${m.path} (mode=${m.options.mode})`);
}
});
});
});
/*
print codehashes
*/
if (options.print) {
dupeFinder.hashSourceCode(data.toString('utf-8'))
.then(results => {
results.forEach(x => {
let result = {
name: x.name,
hash: x.hash,
options: x.options,
path: `${options.basePath}${fpath}`
};
console.log(JSON.stringify(result));
});
});
}
/*
find similar contracts
*/
if (options.compare) {
dupeFinder.compareSourceCode(data.toString('utf-8'), fpath)
.then(results => {
Object.keys(results.results).forEach(contractName => {
let resultobj = results.results[contractName];
console.log(`**** MATCH ****: ${resultobj.target.path} :: ${resultobj.target.name}`);
for (let m of resultobj.matches) {
console.log(` :: ${m.name} :: ${m.path} (mode=${m.options.mode})`);
}
});
});
}
v0.0.11
FAQs
A tool to check if a contract is similar (exact/fuzzy AST based comparison) to a set of known/common contracts like openzeppelin's
The npm package solidity-doppelganger receives a total of 147 weekly downloads. As such, solidity-doppelganger popularity was classified as not popular.
We found that solidity-doppelganger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.