@abcoathup how about in the case of an upgradeable contract? Do we just verify all 3 associated contracts? Would love an example if you have the time. Will be tinkering in the mean time and will post any solutions I happen across.
Hi @lustig,
For upgradeable contracts, the proxy and ProxyAdmin should already be verified on most public networks. Let me know if they are not and we can help verify.
You just need to verify the implementation contract.
If using Etherscan, you can then mark the proxy contract as a proxy:
I did see that linked article in another post on Etherscan but my contract address on Etherscan did not have that button.
I’m going to try verifying the contract address through the truffle plugin and will reread the instructions and see if the situation is resolved. I’ll post contract addresses in the next post.
@abcoathup Sorry, I’ve tried verifying via the CLI and no luck.
Here is my commit where I add the verification content to my truffle-config.js
: https://github.com/technoplato/nash/commit/b37f4be991937ef03a7429afd123b94354889661
When I run npx truffle run verify NashCoin --network rinkeby
, the following is my output. Is there a way to debug this?
Verifying NashCoin
Fail - Unable to verify
Failed to verify 1 contract(s): NashCoin
I was able to ‘verify’ the contract by using the truffle-flattener
but it does not appear to be functioning properly as it indicates that I have no balance when I should have a non-zero amount. https://rinkeby.etherscan.io/address/0x245d429bd51fb52c373753f2927fedcd4319d2db#readContract
Here are the three contracts associated with NashCoin
:
Since the first two contracts have both the words ‘proxy’ and ‘admin’ in them, I am confused on which is which.
Thanks for any advice on how to proceed.
EDIT: After reading more, I’ve found Andrew’s recommendation to try One Click Dapp and setting that up allowed me to read and write to my contract, while providing the ‘AdminUpgradeabilityProxy’ contract address along with the ABI
from the actual implementation here. This feels hacky to me, and I still can’t verify and interact with the contract in the same location, which is my desired behavior.
Here is the results of adding the Implementation Contract ABI to a One Click Dapp that uses the AdminUpgradeabilityContract’s address. NOTE: This is functioning properly, but I can’t see the source code that’s running, which is desired behavior.
Hi @lustig,
As you had verified your implementation contract on Etherscan I marked it on Etherscan as a proxy:
You can now use Etherscan to interact with your upgradeable contract:
https://rinkeby.etherscan.io/address/0x430aa84f31545992988d520dab48c587380c63ef#readProxyContract
You can try: https://github.com/rkalis/truffle-plugin-verify#debugging
You are looking at your implementation contract. When interacting with an upgradeable contract we need to interact using the proxy.
Have a look at the documentation:
@abcoathup Thank you that information was very helpful.
I am now able to consistently “deploy” my upgradeable smart contract and verify it on etherscan by use of the truffle-flattener
plugin. I would like to be able to verify the contract without flattening it, as you’ve pointed out in other forum posts is better for readability and scalability. Since the command line interface is not working for me to verify the single, unflattened contract, do you have any other recommendations?
My second (and potentially last) challenge for the moment is that my “upgrades” of the implementation proxy appear to be deploying new contracts altogether. I can go and verify the contract and interact with it via Etherscan, but I can’t upgrade the existing Implementation Contract on Rinkeby. I’ve tested this locally as well with the ganache-cli
and I can’t get the previous state of the implementation contract to split. Here’s my branch where I’m trying to do so: https://github.com/technoplato/nash/tree/upgrading
I even have a test as advised from the documentation on unit testing the upgrade - which passes - but I’m not sure how: https://github.com/technoplato/nash/blob/upgrading/test/NashCoin.test.ts#L78-L87
Hi @lustig,
You should be able to use https://github.com/rkalis/truffle-plugin-verify#debugging with the implementation address. If you get stuck, please create a new topic with your Solidity, address etc.
In your migrations you are actually deploying a new contract using deployProxy
.
https://github.com/technoplato/nash/blob/upgrading/migrations/3_nash_v3.js#L7
You need to get the address of the proxy and just call upgradeProxy
.
See the following example from the documentation:
// migrations/MM_upgrade_box_contract.js
const { upgradeProxy } = require('@openzeppelin/truffle-upgrades');
const Box = artifacts.require('Box');
const BoxV2 = artifacts.require('BoxV2');
module.exports = async function (deployer) {
const existing = await Box.deployed();
const instance = await upgradeProxy(existing.address, BoxV2, { deployer });
console.log("Upgraded", instance.address);
};
_From: https://docs.openzeppelin.com/upgrades-plugins/1.x/truffle-upgrades#migrations-usage_
We can unit test our implementation contracts, just like any other contract and deploy using .new
.
We can also write higher level tests using deployProxy
and upgradeProxy
.
For an example please see OpenZeppelin Upgrades: Step by Step Tutorial for Truffle
Also the example in the documentation: https://docs.openzeppelin.com/upgrades-plugins/1.x/truffle-upgrades#test-usage
As an aside, I recommend creating a new topic per major question so that anyone can answer.
I'm having this same issue. truffle run verify ContractName --network rinkeby
works for me but it only seems to verify the proxy and not the logic contract the proxy deployed. I haven't tried flattening yet but it doesn't seem a very efficient way of doing this quickly. Isn't there any way to verify a contract deployed by another contract using Truffle?
Hi, can you please verify ERC1967Proxy on optimistic.etherscan.io?
Hi @Shashvat_Mohane, can you let us know which proxy address you would like us to help verify on Optimism? Alternatively, you can use the Solc JSON input file here to verify the proxy contracts on any network.
Hi @ericglau, https://optimistic.etherscan.io/address/0xf18acc02628009231d7baaf9a7a24c0860dda6cb
This is the address that I'm trying to verify.
Hi @Shashvat_Mohane, your proxy is now verified.
Can someone kindly help with verifying mine? https://goerli.etherscan.io/address/0x660Adbbe053fa26C902d92e1579ceF6088B2A079.
My Proxy and Admin contracts are verified, however the implementation isn't verified yet