Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

"Invalid constructor arguments" error, running immediately after deployment #34

Closed
mcplums opened this issue Aug 27, 2020 · 21 comments
Closed
Labels
bug Something isn't working waiting Waiting for response from reporter

Comments

@mcplums
Copy link

mcplums commented Aug 27, 2020

Hello, I'm running:

truffle migrate --network mainnet --reset

And then I'm immediately running

truffle run verify ContractName@address --network mainnet

and I get "Invalid constructor arguments provided. Please verify that they are in ABI-encoded format".

How can they be invalid when I've only just deployed it?

Btw. I love this plugin so much :) it has worked many times in the past

@rkalis
Copy link
Owner

rkalis commented Aug 28, 2020

Hey @mcplums! That does sound weird. Could you run the command again with the --debug flag and post the details? Also, did you deploy your contract through a factory contract?

@mcplums
Copy link
Author

mcplums commented Aug 31, 2020

I have tried to re-create this error and this time using the --debug flag, this time I'm getting 503 error which I assume is a problem at etherscan's end so I will try again later and report back. If I take too long to do so feel free to close 👍

I can confirm it was not a factory. I'm aware that etherscan cannot handle those just yet.

@rkalis
Copy link
Owner

rkalis commented Oct 1, 2020

Any news on this?

@storming0x
Copy link

Getting the same error. When i add --debug

Constructor parameters received: 0x697066735822122009eb274d752106666b7b763e3ba5a150b94b8bf7d130791f17324bb70e54903e64736f6c634300060c0033000000000000000000000000c1dcb653a21e3c0069fe494cbe1644206c641ff6
...other output

"constructorArguements": "697066735822122009eb274d752106666b7b763e3ba5a150b94b8bf7d130791f17324bb70e54903e64736f6c634300060c0033000000000000000000000000c1dcb653a21e3c0069fe494cbe1644206c641ff6"

The payload to etherscan API is missing the '0x' from the beginning

@rkalis
Copy link
Owner

rkalis commented Oct 23, 2020

Hey @dmolina79, thanks for chipping in!

That should be fine, Etherscan doesn't expect the 0x prefix. So I assume there's something else going on. Do you have a repository I can look at to try to reproduce this?

@storming0x
Copy link

storming0x commented Oct 27, 2020

Hi @rkalis sure, i've created this repo as an example

https://github.com/dmolina79/yearn-truffle-verify

Trying to verify this contract in rinkeby using this command:

truffle run verify StrategyCreamCRV@0xF477479a6bf71F41b8935EFDd347D1794F18e6C1 --network infuraRinkeby --license GPL-3.0

These are the compiler settings which should be good:
Compiling contracts... Solc version: 0.6.12 Optimizer: Enabled Runs: 200 EVM Version: Istanbul

The plugin has worked great so far with other simpler contracts, but it bricks on this one with the constructor error for some reason. Lmk if you need anything else.

@rkalis
Copy link
Owner

rkalis commented Oct 27, 2020

So it looks like it somehow retrieved incorrect constructor arguments. When I ran it on my end it retrieved this as the constructor arguments: 0x000000000000000000000000f2e47c29fc9f31cc50a62dea24956545772921bc, which are completely different from the ones you got.

When running with the installed version v0.4.0, I did get an error because the flattened source code included multiple SPDX license identifiers. As a fix, I updated to the latest version v0.5.0 (which uses multi-file verification) and I was able to verify the contract.

I was able to run migrations and accurately verify those newly deployed contracts as well. I'm still not sure why it got different constructor args on your end than on my end, but I can't reproduce the issue. Could you try updating to v0.5.0 and running compile + migrate + verify again to see if it's working for you?

@Grandthrax
Copy link

Hi, I am getting the same issue @dmolina79. When running verify it gets my contructor parameters received as: 0x00000000005d3a536e4d6dbd6114cc1ead35777bab948e3643a26469706673582212203f6b1b16b84a192fc410f2b7252382703c506f806748d5f6b2299317b56927cc64736f6c634300060c00330000000000000000000000009b142c2cdab89941e9dcd0b6c1cf6dea378a8d7c

when they should be:
0x0000000000000000000000009B142C2CDAb89941E9dcd0B6C1cf6dEa378A8D7C

This is a different project to @dmolina79 but we are both built off the same baseStrategy.sol
Is there a way to declare contructor arguments manually?

@rkalis
Copy link
Owner

rkalis commented Oct 27, 2020

That is so odd that it works on my end. Could you guys share your Truffle versions as well?

@Grandthrax
Copy link

Truffle v5.1.50 (core: 5.1.50)
Solidity - 0.6.12 (solc-js)
Node v12.18.2
Web3.js v1.2.9

@storming0x
Copy link

So it looks like it somehow retrieved incorrect constructor arguments. When I ran it on my end it retrieved this as the constructor arguments: 0x000000000000000000000000f2e47c29fc9f31cc50a62dea24956545772921bc, which are completely different from the ones you got.

When running with the installed version v0.4.0, I did get an error because the flattened source code included multiple SPDX license identifiers. As a fix, I updated to the latest version v0.5.0 (which uses multi-file verification) and I was able to verify the contract.

I was able to run migrations and accurately verify those newly deployed contracts as well. I'm still not sure why it got different constructor args on your end than on my end, but I can't reproduce the issue. Could you try updating to v0.5.0 and running compile + migrate + verify again to see if it's working for you?

thanks a lot @rkalis updating the plugin to 0.5.0 did the trick, so it was not the abi constructor issue it was the mix licenses, but that worked in any case.

@Grandthrax
Copy link

Grandthrax commented Oct 27, 2020

I cloned @dmolina79 repo and added my contract, but still getting the same constructor error when trying to verify.

Here is the repo: https://github.com/Grandthrax/yearn-truffle-verify

And I am running command:
truffle run verify YearnDaiCompStratV2@0x5b62F24581Ea4bc6d6C5C101DD2Ae7233E422884 --network infuraMainnet

@Grandthrax
Copy link

I am using truffle-plugin-verify@0.5.0.

Error is: Invalid constructor arguments provided. Please verify that they are in ABI-encoded format

Constructor parameters retrieved: 0xcf6dea378a8d7c

so I am now getting different constructor parameters, but still the wrong ones...

@rkalis
Copy link
Owner

rkalis commented Oct 27, 2020

Strange. Do you have a link to your forked repo with your contract added?

@Grandthrax
Copy link

yes here: https://github.com/Grandthrax/yearn-truffle-verify
YearnDaiCompStratV2.sol in contracts/strategies

@Grandthrax
Copy link

Grandthrax commented Oct 28, 2020

So looking into it a bit more it seems that 'Invalid constructor arguments provided error' just happens when the transaction data is a different length to the artifact.bytecode.length. So probably something I am doing wrong rather than an error on your end

@rkalis
Copy link
Owner

rkalis commented Oct 28, 2020

So the way the plugin works is it gets the contract creation transaction. The input data of that transaction is the contract bytecode + the constructor args. By splitting the input data on the bytecode length, what should be left over is the constructor args. But if the bytecode doesn't match, then it's possible that the split is wrong.

So are you absolutely sure that the compile settings that you used locally are exactly the same as the ones you used when deploying? i.e.:

	compilers: {
		solc: {
			version: "0.6.12",
			settings: {
				optimizer: {
					enabled: true,
					runs: 200
				},
			},
		}
	},

@Grandthrax
Copy link

I compiled and deployed using brownie rather than truffle. So have redeployed (0xd1da63f8ab9b8ce335f0f0e40f0e2a05c20c93bf) using truffle from the repo i linked to above. Now constructor parameters look right but verify is still failing.

One thing I did have to do was edit the json build file for truffle-plugin-verify to work. I was getting "Cannot find module '/D/Source/....l'" so changed all /D/ to D:/. Would that change the result of verify?

@rkalis
Copy link
Owner

rkalis commented Oct 29, 2020

Which fields did you have to change the paths for in the JSON file?

@rkalis
Copy link
Owner

rkalis commented Oct 29, 2020

Also could you push the migration code that you used to the library?

@rkalis
Copy link
Owner

rkalis commented Dec 9, 2020

Closing this issue for inactivity. Feel free to open it with more information.

@rkalis rkalis closed this as completed Dec 9, 2020
@rkalis rkalis added bug Something isn't working waiting Waiting for response from reporter labels May 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working waiting Waiting for response from reporter
Projects
None yet
Development

No branches or pull requests

4 participants