Aniket-Engg / sol-verifier

Verify Solidity smart contracts on Etherscan
MIT License
30 stars 15 forks source link

Constructor Arguments - Fail - Unable to verify #22

Closed digvjs closed 5 years ago

digvjs commented 5 years ago

The verification process fails when contract needs constructor arguments during verification. I have deployed my contract using ether.js library. The verification process fails only for the contracts having constructor with arguments.

Contract Deployed using Ether.js:

let factory = new ethers.ContractFactory(contractABI, contractBytecode, wallet);
let contract = await factory.deploy(tokenSymbol, projectName, numOfTokens);

tokenSymbol, projectName, numOfTokens are the arguments for contract constructor

Inputs for sol-verifier:

var data = {
                key: etherscanAPIKey,
                path : path.join(__dirname, '../../ERC20-Mintable-Contract/erc20_mintable_contract.sol'),
                contractAddress:  contractAddress,
                network  : contractConfig.PROVIDER,
                contractName: contractName,
                cvalues: [tokenSymbol, projectName, numOfTokens],
                optimizationFlag: false
};

The same arguments I am passing while verification as that while deploying smart contract.

Output:

{
    "status": false,
    "message": "Fail - Unable to verify"
}

Contracts for reference: 0xa7a3373419dc09740a6D5c7c308230aB37581984 [Manually Verified with etherscan.io] 0x5Cb0832FA136486E15a2271E06f341c81f7d8602 [Fails to verify using sol-verifier]

I am sure this fails because of constructor arguments, because I tried one without arguments and it passed.

Thanks!

Aniket-Engg commented 5 years ago

Thanks for raising this @DigvijaySS . Let me check it.

Aniket-Engg commented 5 years ago

I checked contract 0xa7a3373419dc09740a6D5c7c308230aB37581984 verified as a similar match. I see you defined constructor with function contractName() syntax which got deprecated in Solidity v0.5.0 by new constructor() syntax which was introduced in v0.4.22.

Although we will provide support for old syntax too. This will be fixed in upcoming release.

digvjs commented 5 years ago

Good to hear that! Thanks @Aniket-Engg