rkalis / truffle-plugin-verify

✅ Verify your smart contracts on Etherscan from the Truffle CLI
https://kalis.me/verify-truffle-smart-contracts-etherscan/
MIT License
467 stars 130 forks source link

Output the standard json #172

Closed tomw1808 closed 1 year ago

tomw1808 commented 2 years ago

Working with multiple block explorers, sometimes it would be great to just output the standard json, so it can be uploaded to verify manually.

My current work-around is to change the verify.js slightly, so it outputs the standard json (line 173)

...
 const postQueries = {
    apikey: options.apiKey,
    module: 'contract',
    action: 'verifysourcecode',
    contractaddress: artifact.networks[`${options.networkId}`].address,
    sourceCode: JSON.stringify(inputJSON),
    codeformat: 'solidity-standard-json-input',
    contractname: `${relativeFilePath}:${artifact.contractName}`,
    compilerversion: compilerVersion,
    constructorArguements: encodedConstructorArgs
  }

  try {
    logger.debug('Sending verify request with POST arguments:')
    logger.debug(JSON.stringify(postQueries, null, 2))
    return console.log(postQueries.sourceCode);
...

and then run

truffle run verify MyContract --network someNetwork > MyContract.json

and then manually clean up the json, remove the logger-lines at the beginning and end.

Then upload the standard json to blockscout and others.

It would be great if that could be automated with a flag like --output-json MyContract.json or so.

rkalis commented 2 years ago

I agree, that would be a great feature. I'll happily take any PRs for this functionality. I can also implement it, but I don't have an estimate for when I'll be able to get to it.

nodezy commented 2 years ago

Would this help when bscscan API is down (happens all the time) and you could manually verify with the JSON? It seems directly verifying on the website still works even when the API is down; would be nice to have a fallback for when that happens...

0xV4L3NT1N3 commented 2 years ago

I do use this plugin to generate a Solc JSON Input when the need arises!

https://github.com/mhrsalehi/truffle-plugin-stdjsonin

rkalis commented 2 years ago

Very cool @0xV4L3NT1N3, didn't know about this plugin! @mhrsalehi is there any chance you'd be open to contributing a PR integrating that "export Input JSON" functionality to truffle-plugin-verify (e.g. with a --export-json <file> flag)?

rkalis commented 1 year ago

Since Truffle is being sunset, I don't plan to add new features, so I'm closing this issue.