Polygon mainnet can’t verify TransparentUpgradeableProxy, Error! Invalid constructor arguments provided. Please verify that they are in ABI-encoded format

Background story

I'm sorry. over the last weeks, I posted many questions. Before asking questions, I tried and asked AI.

I have already verified implementation contract, GitHub code: https://github.com/WarriorFromLongAgo/fishcake-contracts/blob/v0_0_2_nft_image/src/contracts/core/token/NftManagerV3.sol
In polygon implementation contract: 0xa270aeebca041c5c7735f7b9cfd9d80527f3ebae
In polygon transparentproxy contract: 0x2f2cb24bab1b6e2353ef6246a2ea4ce50487008b

When I was verifying the transparentproxy contract, I had some questions.

environment

window
foundry
forge solc version = 0.8.26

i read and tried the these posts

I have already read and tried the following post
https://forum.openzeppelin.com/t/verifying-transparentupgradeableproxy-on-boba-network/22943
https://forum.openzeppelin.com/t/how-to-verify-a-contract-on-etherscan-bscscan-polygonscan/14225
https://forum.openzeppelin.com/t/can-not-verify-transparentupgradeableproxy-error-invalid-constructor-arguments-provided-please-verify-that-they-are-in-abi-encoded-format/40824/2
https://forum.openzeppelin.com/t/error-invalid-constructor-arguments-provided-please-verify-that-they-are-in-abi-encoded-format/2241
https://forum.openzeppelin.com/t/invalid-constructor-arguments-provided-please-verify-that-they-are-in-abi-encoded-format/28926
https://forum.openzeppelin.com/t/error-invalid-constructor-arguments-provided-please-verify-that-they-are-in-abi-encoded-format-even-with-correct-abi-encoded-args-provided/28610

question

get implementation contract address

cast storage 0x2F2Cb24BaB1b6E2353EF6246a2Ea4ce50487008B 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc --rpc-url "$env:RPC_URL"

0x000000000000000000000000A270aeebCa041C5C7735f7B9cfD9D80527F3EbaE

get proxy admin address

cast storage 0x2F2Cb24BaB1b6E2353EF6246a2Ea4ce50487008B 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103 --rpc-url "$env:RPC_URL"

0x000000000000000000000000dcb0a67c43531ec2312869edf67967e06a186570

get owner address

cast call 0x2F2Cb24BaB1b6E2353EF6246a2Ea4ce50487008B "owner()" --rpc-url "$env:RPC_URL"

0x000000000000000000000000d79053a14bc465d9c1434d4a4fabdea7b6a2a94b 

define variables for executing commands

0xD79053a14BC465d9C1434d4A4fAbdeA7b6a2A94b = owner address
0x84eBc138F4Ab844A3050a6059763D269dC9951c6 = proxy fccToken address
0xc2132D05D31c914a87C6611C10748AEb04B58e8F = usdt address
0x036423643CEB603B7aff40A05627F09C04b9897E = redemptionPool Address
0xA270aeebCa041C5C7735f7B9cfD9D80527F3EbaE = implementation contract address
0xD79053a14BC465d9C1434d4A4fAbdeA7b6a2A94b = owner address
0x2F2Cb24BaB1b6E2353EF6246a2Ea4ce50487008B = transparentproxy address

Windows Execute Command

$ENCODED_INITIALIZE_DATA = (cast abi-encode "initialize(address,address,address,address)" 0xD79053a14BC465d9C1434d4A4fAbdeA7b6a2A94b 0x84eBc138F4Ab844A3050a6059763D269dC9951c6 0xc2132D05D31c914a87C6611C10748AEb04B58e8F 0x036423643CEB603B7aff40A05627F09C04b9897E)

$CONSTRUCTOR_ARGS = (cast abi-encode "constructor(address,address,bytes)" 0xA270aeebCa041C5C7735f7B9cfD9D80527F3EbaE 0xD79053a14BC465d9C1434d4A4fAbdeA7b6a2A94b $ENCODED_INITIALIZE_DATA)

forge verify-contract 0x2F2Cb24BaB1b6E2353EF6246a2Ea4ce50487008B TransparentUpgradeableProxy --chain polygon --constructor-args $CONSTRUCTOR_ARGS

Windows Execution Results

Start verifying contract `0x2F2Cb24BaB1b6E2353EF6246a2Ea4ce50487008B` deployed on polygon

Submitting verification for [lib/openzeppelin-contracts\contracts/proxy/transparent/TransparentUpgradeableProxy.sol:TransparentUpgradeableProxy] 0x2F2Cb24BaB1b6E2353EF6246a2Ea4ce50487008B.
Submitted contract for verification:
        Response: `OK`
        GUID: `kw2vsmrfzk4aukmyppbvgy4piitnjlguhha931erswbf61ajg6`
        URL: https://polygonscan.com/address/0x2f2cb24bab1b6e2353ef6246a2ea4ce50487008b

I tried for hours(google or ai), but the verification failed.

Contract Address 0x2f2cb24bab1b6e2353ef6246a2ea4ce50487008b | PolygonScan

In the polygon scan, I tried the 'Verify and Publish' button, but the verification failed.

End

Never mind, it is better to ask a good question than to find a good solution.

I think maybe there is something wrong the variable ENCODED_INITIALIZE_DATA, you use cast abi-encode, I think it can encode the given function argument, but without the selector.

i find two question:

  1. When running the forge verify-contract command, the --watch parameter was missing, so it didn't watch error responses.
  2. Adding the method selector still didn't work.
$INITIALIZE_SELECTOR = (cast sig "initialize(address,address,address,address)")

$ENCODED_INITIALIZE_DATA = (cast abi-encode "initialize(address,address,address,address)" 0xD79053a14BC465d9C1434d4A4fAbdeA7b6a2A94b 0x84eBc138F4Ab844A3050a6059763D269dC9951c6 0xc2132D05D31c914a87C6611C10748AEb04B58e8F 0x036423643CEB603B7aff40A05627F09C04b9897E)

$FULL_ENCODED_INITIALIZE_DATA = "0x$($INITIALIZE_SELECTOR.Substring(2))$($ENCODED_INITIALIZE_DATA.Substring(2))"

$CONSTRUCTOR_ARGS = (cast abi-encode "constructor(address,address,bytes)" 0xA270aeebCa041C5C7735f7B9cfD9D80527F3EbaE 0xD79053a14BC465d9C1434d4A4fAbdeA7b6a2A94b $FULL_ENCODED_INITIALIZE_DATA)

forge verify-contract --watch 0x2F2Cb24BaB1b6E2353EF6246a2Ea4ce50487008B "lib/openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol:TransparentUpgradeableProxy" --chain polygon --constructor-args "$CONSTRUCTOR_ARGS"

response

Start verifying contract `0x2F2Cb24BaB1b6E2353EF6246a2Ea4ce50487008B` deployed on polygon

Submitting verification for [lib/openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol:TransparentUpgradeableProxy] 0x2F2Cb24BaB1b6E2353EF6246a2Ea4ce50487008B.
Submitted contract for verification:
        Response: `OK`
        GUID: `cu2lvulukrueaahz7w4gfviqqpse3tfamzs1wvi4n8g8kkt5mv`
        URL: https://polygonscan.com/address/0x2f2cb24bab1b6e2353ef6246a2ea4ce50487008b
Contract verification status:
Response: `NOTOK`
Details: `Pending in queue`
Contract verification status:
Response: `NOTOK`
Details: `Fail - Unable to verify. Please check if the correct constructor argument was entered.`
Error:
Checking verification result failed

Context:
- Contract failed to verify.


1 Like

Great, this time you encoded parameters with function selector.

I think maybe there is something wrong with your constructor parameters, so I use another verify flag --guess-constructor-args to verify your proxy contract, it works.
And indeed, you provide a wrong value for the parameter logic, it should be 0xFdB34C035bc8aE53E96754be618f668953112eF2.

Use more, and ask more, and solve more, and finally, you will be more and more better.

forge verify-contract \
    0x2F2Cb24BaB1b6E2353EF6246a2Ea4ce50487008B \
    TransparentUpgradeableProxy \
    --rpc-url "xxx" \
    --guess-constructor-args \
    --etherscan-api-key "xxx"

Start verifying contract `0x2F2Cb24BaB1b6E2353EF6246a2Ea4ce50487008B` deployed on polygon
Identified constructor arguments: 000000000000000000000000fdb34c035bc8ae53e96754be618f668953112ef2000000000000000000000000d79053a14bc465d9c1434d4a4fabdea7b6a2a94b00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000084f8c8765e000000000000000000000000d79053a14bc465d9c1434d4a4fabdea7b6a2a94b00000000000000000000000084ebc138f4ab844a3050a6059763d269dc9951c6000000000000000000000000c2132d05d31c914a87c6611c10748aeb04b58e8f000000000000000000000000036423643ceb603b7aff40a05627f09c04b9897e00000000000000000000000000000000000000000000000000000000

Submitting verification for [lib/openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol:TransparentUpgradeableProxy] 0x2F2Cb24BaB1b6E2353EF6246a2Ea4ce50487008B.
Submitted contract for verification:
        Response: `OK`
        GUID: `xxx`
        URL: https://polygonscan.com/address/0x2f2cb24bab1b6e2353ef6246a2ea4ce50487008b
1 Like

In the local forge broadcast file, I found the answer in the JSON.
Thank you very much. Can you provide the EOA address?(EVM L1/L2)

my gmail is hubeixuegao@gmail.com

    {
      "hash": "0xec4b19295a540e908c4878aad54669f98a3b2303242e8fedda95169d52ca4325",
      "transactionType": "CREATE",
      "contractName": "NftManager",
      "contractAddress": "0xfdb34c035bc8ae53e96754be618f668953112ef2",
      "function": null,
      "arguments": null,
      "transaction": {
        "from": "0xd79053a14bc465d9c1434d4a4fabdea7b6a2a94b",
        "gas": "0x30297f",
        "value": "0x0",
        "input": "0x608080604052346015",
        "nonce": "0xad",
        "chainId": "0x89"
      },
      "additionalContracts": [],
      "isFixedGasLimit": false
    },
    {
      "hash": "0x3289dc941eaec073bc4ab0ccfa7d15800bc3edbbcb5597aab05db376b966f865",
      "transactionType": "CREATE",
      "contractName": "TransparentUpgradeableProxy",
      "contractAddress": "0x2f2cb24bab1b6e2353ef6246a2ea4ce50487008b",
      "function": null,
      "arguments": [
        "0xFdB34C035bc8aE53E96754be618f668953112eF2",
        "0xD79053a14BC465d9C1434d4A4fAbdeA7b6a2A94b",
        "0xf8c8765e000000000000000000000000d79053a14bc465d9c1434d4a4fabdea7b6a2a94b00000000000000000000000084ebc138f4ab844a3050a6059763d269dc9951c6000000000000000000000000c2132d05d31c914a87c6611c10748aeb04b58e8f000000000000000000000000036423643ceb603b7aff40a05627f09c04b9897e"
      ],
      "transaction": {
        "from": "0xd79053a14bc465d9c1434d4a4fabdea7b6a2a94b",
        "gas": "0xf552e",
        "value": "0x0",
        "input": "0x60a06",
        "nonce": "0xae",
        "chainId": "0x89"
      },
      "additionalContracts": [
        {
          "transactionType": "CREATE",
          "address": "0xdcb0a67c43531ec2312869edf67967e06a186570",
          "initCode": "0x60803460b857601f61044"
        }
      ],
      "isFixedGasLimit": false
    }
1 Like