menu
announcement

Spectrum is now read-only. Learn more about the decision in our official announcement.

Channels
Team

Can't verify my smart contract on Etherscan (truffle teams)

October 25, 2020 at 2:52pm

Can't verify my smart contract on Etherscan (truffle teams)

October 25, 2020 at 2:52pm (Edited 12 months ago)
Hi !
Just deployed my smart contract on Ropsten with Truffle Teams : https://ropsten.etherscan.io/address/0x0944c5D45f4DeC0275Fe3901C5f7f92Ffc5482C3
It works perfectly ! But I can't verify the contract on Etherscan :(
I tried : "truffle-flattener contracts/mycontract.sol > flat.sol" Then copy the file content, with the correct solidity version (I checked the version in my deployment console). With or without optimisation doesn't change anything. I tried different compilers.
Also, I tried to use the artifact file.
Error! Unable to generate Contract ByteCode and ABI (General Exception, unable to get compiled [bytecode])
Am I missing something ?

October 25, 2020 at 5:07pm
Unfortunately we don't currently have a set of instructions on how to verify contracts deployed with Truffle Teams. It's possible that you should be able to download the artifacts (Unfortunately we don't currently have a set of instructions on how to verify contracts deployed with Truffle Teams. It's possible that you should be able to download the artifacts (you can download a zip of the deployed artifacts from teams either from actions drop-down in Deployments Unfortunately we don't currently have a set of instructions on how to verify contracts deployed with Truffle Teams. It's possible that you should be able to download the artifacts (Unfortunately we don't currently have a set of instructions on how to verify contracts deployed with Truffle Teams. It's possible that you should be able to download the artifacts (you can download a zip of the deployed artifacts from teams either from actions drop-down in Deployments view or in the context menu on the top right of a deployment card in the pipeline view) the deployment, put them in your build/contracts directory locally, and use the https://github.com/rkalis/truffle-plugin-verify plugin to verify the contracts. I may be able to give it a shot on Monday during business hours and see if I can come up with some preliminary instructions.

December 28, 2020 at 1:11am
Did anything ever come of this because i just ran into this as well trying to deploy on ropsten.

December 28, 2020 at 11:12pm
(tfinch) Unfortunately I didn't get the chance to write anything up that I mentioned in my prior message. However, I left Truffle at the end of November so I'm not sure of any other changes were put in since then. Perhaps (honestbonsai), (eshaben), or (discriskandbisque) can speak more to this.
Edited

January 6, 2021 at 5:29am
hey (tfinch)! Unfortunately we haven't had any new changes since Mike left at the end of November. I'll take ownership of this moving forward and try to get a solution documented and back to you soon!

January 8, 2021 at 7:25am
(maxime-brugel) (tfinch) I have some updates for you! 👇
So I ran into some interesting problems while looking at this issue but I was able to verify my contracts that I deployed to ropsten using two different methods: Etherscan's publish and verify feature and the truffle-plugin-verify plugin.
If you want to verify using Etherscan, head over to ropsten.etherscan.io/verifyContract. Enter the address of the contract you would like to verify. Select the compiler type. If it's a simple contract that is contained within a single file select the Solidity (Single file) option. I tried using the Solidity (Standard-Json-Input) compiler and downloading the artifacts from Truffle Teams, but this is where I ran into the same error mentioned above: General Exception, unable to get compiled [bytecode]. So I don't recommend going that route for the time being as I don't know why that is happening and would have to further investigate the issue there. Next, select the compiler version. This must match the deployed contracts compiled version. If you have any doubt of the version for this specific deployment, you can download the artifacts. Open and search the contract's artifact for "compiler" to find which version was used. If you specified a license for the contract select which license or if a license was not specified choose 1) No license. Now enter the source code of the contract and then verify and publish. It should work without any errors.
If you want to verify using truffle-plugin-verify, head over to https://github.com/rkalis/truffle-plugin-verify and follow the steps in the readme to configure the plugin. You'll also need to update the networks object within truffle-config.js to include the network_id of the network you deployed to. Since I deployed to ropsten, my entry for ropsten looked like this:
networks: {
ropsten: {
network_id: 3
}
},
Next you'll want to download the artifacts for the deployment as you'll want to add those to your local Truffle project. Within your Truffle project you might already have build/contracts directories, if so, we're going to replace those files with the downloaded artifacts. If you do not already have the build/contracts directories add them to the root of your project. Then add the downloaded artifact files directly inside the contracts directory. The next step is going to be a weird one as you'll have to make some manual changes to the artifact files. Search each of the artifact files for "/home/builduser/teams_workingdir/repo/contracts/", you'll need to replace this location with the actual location of each of your contracts. Truffle Teams clones your repository into a remote environment and the path provided in the artifacts is where it lives in the remote environment but to use the plugin the path needs to point to where the contract exists on your local machine. So as long as the path is changed and pointed to the .sol file of your contract locally, the plugin will be able to verify your contracts. I understand it's not the best way but it's an option.
If you have any questions at all, please do not hesitate to reach out!

May 22, 2021 at 3:05am
I tried the steps you mentioned to verify my erc721 upgradeable contract. I ensured the compiler was correct (version + commit) and changed the paths to match my local machine. The truffle verify plugin is returning;
npx truffle run verify MyContract--network rinkeby
Verifying MyContract
Fail - Unable to verify
Failed to verify 1 contract(s): MyContract
Is this still the suggested approach to verifying contracts? Is there anything built into teams?