Skip to content

AndreMiras/smart-contract-verifier.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smart Contract Verifier

Tests Documentation npm version

Smart contract verification library.

Makes it possible to verify some contract code against a deployed contract address.

Originally inspired by Shawn's article: Verify Ethereum Contracts Using Web3.js and Solc

Usage example

const { compileExtractCompare } = require("smart-contract-verifier");
const Web3 = require("web3");
const web3 = new Web3(
  new Web3.providers.HttpProvider(process.env.RPC_PROVIDER)
);
const solcVersion = "v0.4.16+commit.d7661dd9";
const contractName = "LinkToken";
const contractFilename = "LinkToken.sol";
const contractAddress = "0x514910771AF9Ca656af840dff83E8264EcF986CA";
// assuming the LinkToken.sol file is on the file system
const contractPath = "./" + contractFilename;
const sources = { [contractFilename]: fs.readFileSync(contractPath, "utf8") };
compileExtractCompare(
  web3,
  sources,
  solcVersion,
  contractName,
  contractFilename,
  contractAddress
).then((matching) => console.log(matching));