I am using Remix try to duplicate a contract and redeploy the original contract is on Etherium and I am trying to redeploy on Polygon, for implementation contract it already verified and the last step is to deploy TransparentUpgradeableProxy
Here is some of Implementation constructor contract
contract PresaleV1 is Initializable, ReentrancyGuardUpgradeable, OwnableUpgradeable, PausableUpgradeable {
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() initializer {}
/**
* @dev Initializes the contract and sets key parameters
* @param _oracle Oracle contract to fetch ETH/USDT price
* @param _usdt USDT token contract address
* @param _startTime start time of the presale
* @param _endTime end time of the presale
* @param _rounds array of round details
* @param _maxTokensToBuy amount of max tokens to buy
* @param _paymentWallet address to recive payments
*/
function initialize(address _oracle, address _usdt, uint256 _startTime, uint256 _endTime, uint256[][3] memory _rounds, uint256 _maxTokensToBuy, address _paymentWallet) external initializer {
require(_oracle != address(0), "Zero aggregator address");
require(_usdt != address(0), "Zero USDT address");
require(_startTime > block.timestamp && _endTime > _startTime, "Invalid time");
__Pausable_init_unchained();
__Ownable_init_unchained();
__ReentrancyGuard_init_unchained();
baseDecimals = (10 ** 18);
aggregatorInterface = Aggregator(_oracle);
USDTInterface = IERC20Upgradeable(_usdt);
startTime = _startTime;
endTime = _endTime;
rounds = _rounds;
maxTokensToBuy = _maxTokensToBuy;
paymentWallet = _paymentWallet;
emit SaleTimeSet(startTime, endTime, block.timestamp);
}
}
It was deployed successfull and then deploy for a TransparentUpgradeableProxy
The Contract was deployed from Import.sol here is a code
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
// Kept for backwards compatibility with older versions of Hardhat and Truffle plugins.
contract AdminUpgradeabilityProxy is TransparentUpgradeableProxy {
constructor(address logic, address admin, bytes memory data) payable TransparentUpgradeableProxy(logic, admin, data) {}
}
I deployed by using a script and logging for ABI-Encoded to input when Verify Contract
// Encode the initialization call for the PresaleV1.sol initialize function
console.log("Encoding initialization function...");
const initializeFunction = new ethers.utils.Interface([
"function initialize(address _oracle, address _usdt, uint256 _startTime, uint256 _endTime, uint256[][3] memory _rounds, uint256 _maxTokensToBuy, address _paymentWallet)"
]);
// Log ABI
console.log("ABI of the initialize function:", initializeFunction.fragments);
const initData = initializeFunction.encodeFunctionData("initialize", [
oracleAddress,
usdtAddress,
startTime,
endTime,
rounds,
maxTokensToBuy,
paymentWallet,
]);
// Log ABI encoded data
console.log("Encoded initialization data:", initData);
// Encode the constructor arguments
console.log("Encoding constructor arguments...");
const constructorArgs = ethers.utils.defaultAbiCoder.encode(
["address", "address", "bytes"],
[logicAddress, adminAddress, initData]
);
// Log ABI encoded constructor arguments
console.log("Encoded constructor arguments:", constructorArgs);
// Deploy the proxy
console.log("Deploying proxy contract...");
let proxy;
try {
proxy = await ProxyFactory.deploy(logicAddress, adminAddress, initData, {
gasLimit: ethers.utils.hexlify(12000000) // Increased gas limit
});
console.log("Proxy contract deployment transaction sent.");
console.log("Proxy deployed at address:", proxy.address);
await proxy.deployed();
console.log("Deployment successful:", proxy.address);
// Update the config file with the new proxy address
updateConfigFile(proxy.address);
} catch (error) {
// Log detailed error information
console.error("Error deploying proxy contract:", error.message, "\nStack trace:", error.stack);
}
and I was deployed to Polygon contract address: 0xab89c21bd14431f8164e8161362fd25ff1f7ae53
and trying to verify by
- Flattern Import.sol
- Input Constructor Argument ABI-Encoded from above "constructorArgs"
but it not working , Could anyone suggest me a step to verify
Here is a log when running deploy script
Encoding initialization function...
ABI of the initialize function:
[{"type":"function","name":"initialize","constant":false,"inputs":[{"name":"_oracle","type":"address","indexed":null,"components":null,"arrayLength":null,"arrayChildren":null,"baseType":"address","_isParamType":true},{"name":"_usdt","type":"address","indexed":null,"components":null,"arrayLength":null,"arrayChildren":null,"baseType":"address","_isParamType":true},{"name":"_startTime","type":"uint256","indexed":null,"components":null,"arrayLength":null,"arrayChildren":null,"baseType":"uint256","_isParamType":true},{"name":"_endTime","type":"uint256","indexed":null,"components":null,"arrayLength":null,"arrayChildren":null,"baseType":"uint256","_isParamType":true},{"name":"_rounds","type":"uint256[][3]","indexed":null,"components":null,"arrayLength":3,"arrayChildren":{"name":null,"type":"uint256[]","indexed":null,"components":null,"arrayLength":-1,"arrayChildren":{"name":null,"type":"uint256","indexed":null,"components":null,"arrayLength":null,"arrayChildren":null,"baseType":"uint256","_isParamType":true},"baseType":"array","_isParamType":true},"baseType":"array","_isParamType":true},{"name":"_maxTokensToBuy","type":"uint256","indexed":null,"components":null,"arrayLength":null,"arrayChildren":null,"baseType":"uint256","_isParamType":true},{"name":"_paymentWallet","type":"address","indexed":null,"components":null,"arrayLength":null,"arrayChildren":null,"baseType":"address","_isParamType":true}],"outputs":[],"payable":false,"stateMutability":"nonpayable","gas":null,"_isFragment":true}]
Encoded initialization data:
0x57405d050000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000666cd98000000000000000000000000000000000000000000000000000000007915f74c000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000003e80000000000000000000000004abfab62016180d304a2dbf7fd4a2b03cda9c922000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000005800000000000000000000000000000000000000000000000000000000000000aa00000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000001ed86c60000000000000000000000000000000000000000000000000000000003db0d8c0000000000000000000000000000000000000000000000000000000005c894520000000000000000000000000000000000000000000000000000000007b61b180000000000000000000000000000000000000000000000000000000009a3a1de000000000000000000000000000000000000000000000000000000000b9128a4000000000000000000000000000000000000000000000000000000000d7eaf6a000000000000000000000000000000000000000000000000000000000f6c3630000000000000000000000000000000000000000000000000000000001159bcf600000000000000000000000000000000000000000000000000000000134743bc000000000000000000000000000000000000000000000000000000001534ca82000000000000000000000000000000000000000000000000000000001722514800000000000000000000000000000000000000000000000000000000190fd80e000000000000000000000000000000000000000000000000000000001afd5ed4000000000000000000000000000000000000000000000000000000001ceae59a000000000000000000000000000000000000000000000000000000001ed86c600000000000000000000000000000000000000000000000000000000020c5f3260000000000000000000000000000000000000000000000000000000022b379ec0000000000000000000000000000000000000000000000000000000024a100b200000000000000000000000000000000000000000000000000000000268e877800000000000000000000000000000000000000000000000000000000287c0e3e000000000000000000000000000000000000000000000000000000002a699504000000000000000000000000000000000000000000000000000000002c571bca000000000000000000000000000000000000000000000000000000002e44a290000000000000000000000000000000000000000000000000000000003032295600000000000000000000000000000000000000000000000000000000321fb01c00000000000000000000000000000000000000000000000000000000340d36e20000000000000000000000000000000000000000000000000000000035fabda80000000000000000000000000000000000000000000000000000000037e8446e0000000000000000000000000000000000000000000000000000000039d5cb34000000000000000000000000000000000000000000000000000000003bc351fa000000000000000000000000000000000000000000000000000000003db0d8c0000000000000000000000000000000000000000000000000000000003f9e5f8600000000000000000000000000000000000000000000000000000000418be64c0000000000000000000000000000000000000000000000000000000043796d12000000000000000000000000000000000000000000000000000000004566f3d80000000000000000000000000000000000000000000000000000000047547a9e0000000000000000000000000000000000000000000000000000000049420164000000000000000000000000000000000000000000000000000000004b2f882a000000000000000000000000000000000000000000000000000000004d1d0ef000000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000110d9316ec000000000000000000000000000000000000000000000000000000112367066580000000000000000000000000000000000000000000000000000011393af5df000000000000000000000000000000000000000000000000000000114f0ee5588000000000000000000000000000000000000000000000000000001164e2d4d2000000000000000000000000000000000000000000000000000000117c2b4bba00000000000000000000000000000000000000000000000000000027ca57357c00000000000000000000000000000000000000000000000000000027d8e47fcd00000000000000000000000000000000000000000000000000000027e771ca1e00000000000000000000000000000000000000000000000000000027f5ff146f00000000000000000000000000000000000000000000000000000028048c5ec0000000000000000000000000000000000000000000000000000000281319a9110000000000000000000000000000000000000000000000000000002821a6f3620000000000000000000000000000000000000000000000000000002830343db3000000000000000000000000000000000000000000000000000000283ec18804000000000000000000000000000000000000000000000000000000284d4ed255000000000000000000000000000000000000000000000000000000285bdc1ca6000000000000000000000000000000000000000000000000000000286a6966f70000000000000000000000000000000000000000000000000000002878f6b148000000000000000000000000000000000000000000000000000000288783fb9900000000000000000000000000000000000000000000000000000028961145ea00000000000000000000000000000000000000000000000000000028a49e903b00000000000000000000000000000000000000000000000000000028b32bda8c00000000000000000000000000000000000000000000000000000028c1b924dd00000000000000000000000000000000000000000000000000000028d0466f2e00000000000000000000000000000000000000000000000000000028ded3b97f00000000000000000000000000000000000000000000000000000028ed6103d000000000000000000000000000000000000000000000000000000028fbee4e21000000000000000000000000000000000000000000000000000000290a7b9872000000000000000000000000000000000000000000000000000000291908e2c30000000000000000000000000000000000000000000000000000002927962d1400000000000000000000000000000000000000000000000000000029362377650000000000000000000000000000000000000000000000000000002944b0c1b600000000000000000000000000000000000000000000000000000029533e0c070000000000000000000000000000000000000000000000000000002961cb5658000000000000000000000000000000000000000000000000000000297058a0a9000000000000000000000000000000000000000000000000000000297ee5eafa000000000000000000000000000000000000000000000000000000298d73354b000000000000000000000000000000000000000000000000000000299c007f9c00000000000000000000000000000000000000000000000000000029aa8dc9ed000000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000661cec2f00000000000000000000000000000000000000000000000000000000661f8ec30000000000000000000000000000000000000000000000000000000066223157000000000000000000000000000000000000000000000000000000006624d3f7000000000000000000000000000000000000000000000000000000006627768b00000000000000000000000000000000000000000000000000000000662a191f00000000000000000000000000000000000000000000000000000000662cbbcb00000000000000000000000000000000000000000000000000000000662f5e6b00000000000000000000000000000000000000000000000000000000663355af00000000000000000000000000000000000000000000000000000000663749c300000000000000000000000000000000000000000000000000000000663b3dd700000000000000000000000000000000000000000000000000000000663f31f7000000000000000000000000000000000000000000000000000000006643260b0000000000000000000000000000000000000000000000000000000066471a1f00000000000000000000000000000000000000000000000000000000664b0e3300000000000000000000000000000000000000000000000000000000664f0253000000000000000000000000000000000000000000000000000000006652f667000000000000000000000000000000000000000000000000000000006656e01f00000000000000000000000000000000000000000000000000000000665ad16f00000000000000000000000000000000000000000000000000000000665e2b1b0000000000000000000000000000000000000000000000000000000066606083000000000000000000000000000000000000000000000000000000006662b44b000000000000000000000000000000000000000000000000000000006665fdbf000000000000000000000000000000000000000000000000000000006669f23f00000000000000000000000000000000000000000000000000000000666de6bf000000000000000000000000000000000000000000000000000000006671db3f000000000000000000000000000000000000000000000000000000006675cfbf000000000000000000000000000000000000000000000000000000006679c43f00000000000000000000000000000000000000000000000000000000667db8bf000000000000000000000000000000000000000000000000000000006681ad3f000000000000000000000000000000000000000000000000000000006685a1bf000000000000000000000000000000000000000000000000000000006689963f00000000000000000000000000000000000000000000000000000000668d8abf0000000000000000000000000000000000000000000000000000000066917f3f00000000000000000000000000000000000000000000000000000000669573bf000000000000000000000000000000000000000000000000000000006699683f00000000000000000000000000000000000000000000000000000000669d5cbf0000000000000000000000000000000000000000000000000000000066a1513f0000000000000000000000000000000000000000000000000000000066a545bf0000000000000000000000000000000000000000000000000000000066a93a3f
Encoding constructor arguments...
Encoded constructor arguments:
0x0000000000000000000000009d32a94b8448b8595675591dec5096bf094f84c10000000000000000000000004abfab62016180d304a2dbf7fd4a2b03cda9c922000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000010a457405d050000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000666cd98000000000000000000000000000000000000000000000000000000007915f74c000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000003e80000000000000000000000004abfab62016180d304a2dbf7fd4a2b03cda9c922000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000005800000000000000000000000000000000000000000000000000000000000000aa00000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000001ed86c60000000000000000000000000000000000000000000000000000000003db0d8c0000000000000000000000000000000000000000000000000000000005c894520000000000000000000000000000000000000000000000000000000007b61b180000000000000000000000000000000000000000000000000000000009a3a1de000000000000000000000000000000000000000000000000000000000b9128a4000000000000000000000000000000000000000000000000000000000d7eaf6a000000000000000000000000000000000000000000000000000000000f6c3630000000000000000000000000000000000000000000000000000000001159bcf600000000000000000000000000000000000000000000000000000000134743bc000000000000000000000000000000000000000000000000000000001534ca82000000000000000000000000000000000000000000000000000000001722514800000000000000000000000000000000000000000000000000000000190fd80e000000000000000000000000000000000000000000000000000000001afd5ed4000000000000000000000000000000000000000000000000000000001ceae59a000000000000000000000000000000000000000000000000000000001ed86c600000000000000000000000000000000000000000000000000000000020c5f3260000000000000000000000000000000000000000000000000000000022b379ec0000000000000000000000000000000000000000000000000000000024a100b200000000000000000000000000000000000000000000000000000000268e877800000000000000000000000000000000000000000000000000000000287c0e3e000000000000000000000000000000000000000000000000000000002a699504000000000000000000000000000000000000000000000000000000002c571bca000000000000000000000000000000000000000000000000000000002e44a290000000000000000000000000000000000000000000000000000000003032295600000000000000000000000000000000000000000000000000000000321fb01c00000000000000000000000000000000000000000000000000000000340d36e20000000000000000000000000000000000000000000000000000000035fabda80000000000000000000000000000000000000000000000000000000037e8446e0000000000000000000000000000000000000000000000000000000039d5cb34000000000000000000000000000000000000000000000000000000003bc351fa000000000000000000000000000000000000000000000000000000003db0d8c0000000000000000000000000000000000000000000000000000000003f9e5f8600000000000000000000000000000000000000000000000000000000418be64c0000000000000000000000000000000000000000000000000000000043796d12000000000000000000000000000000000000000000000000000000004566f3d80000000000000000000000000000000000000000000000000000000047547a9e0000000000000000000000000000000000000000000000000000000049420164000000000000000000000000000000000000000000000000000000004b2f882a000000000000000000000000000000000000000000000000000000004d1d0ef000000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000110d9316ec000000000000000000000000000000000000000000000000000000112367066580000000000000000000000000000000000000000000000000000011393af5df000000000000000000000000000000000000000000000000000000114f0ee5588000000000000000000000000000000000000000000000000000001164e2d4d2000000000000000000000000000000000000000000000000000000117c2b4bba00000000000000000000000000000000000000000000000000000027ca57357c00000000000000000000000000000000000000000000000000000027d8e47fcd00000000000000000000000000000000000000000000000000000027e771ca1e00000000000000000000000000000000000000000000000000000027f5ff146f00000000000000000000000000000000000000000000000000000028048c5ec0000000000000000000000000000000000000000000000000000000281319a9110000000000000000000000000000000000000000000000000000002821a6f3620000000000000000000000000000000000000000000000000000002830343db3000000000000000000000000000000000000000000000000000000283ec18804000000000000000000000000000000000000000000000000000000284d4ed255000000000000000000000000000000000000000000000000000000285bdc1ca6000000000000000000000000000000000000000000000000000000286a6966f70000000000000000000000000000000000000000000000000000002878f6b148000000000000000000000000000000000000000000000000000000288783fb9900000000000000000000000000000000000000000000000000000028961145ea00000000000000000000000000000000000000000000000000000028a49e903b00000000000000000000000000000000000000000000000000000028b32bda8c00000000000000000000000000000000000000000000000000000028c1b924dd00000000000000000000000000000000000000000000000000000028d0466f2e00000000000000000000000000000000000000000000000000000028ded3b97f00000000000000000000000000000000000000000000000000000028ed6103d000000000000000000000000000000000000000000000000000000028fbee4e21000000000000000000000000000000000000000000000000000000290a7b9872000000000000000000000000000000000000000000000000000000291908e2c30000000000000000000000000000000000000000000000000000002927962d1400000000000000000000000000000000000000000000000000000029362377650000000000000000000000000000000000000000000000000000002944b0c1b600000000000000000000000000000000000000000000000000000029533e0c070000000000000000000000000000000000000000000000000000002961cb5658000000000000000000000000000000000000000000000000000000297058a0a9000000000000000000000000000000000000000000000000000000297ee5eafa000000000000000000000000000000000000000000000000000000298d73354b000000000000000000000000000000000000000000000000000000299c007f9c00000000000000000000000000000000000000000000000000000029aa8dc9ed000000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000661cec2f00000000000000000000000000000000000000000000000000000000661f8ec30000000000000000000000000000000000000000000000000000000066223157000000000000000000000000000000000000000000000000000000006624d3f7000000000000000000000000000000000000000000000000000000006627768b00000000000000000000000000000000000000000000000000000000662a191f00000000000000000000000000000000000000000000000000000000662cbbcb00000000000000000000000000000000000000000000000000000000662f5e6b00000000000000000000000000000000000000000000000000000000663355af00000000000000000000000000000000000000000000000000000000663749c300000000000000000000000000000000000000000000000000000000663b3dd700000000000000000000000000000000000000000000000000000000663f31f7000000000000000000000000000000000000000000000000000000006643260b0000000000000000000000000000000000000000000000000000000066471a1f00000000000000000000000000000000000000000000000000000000664b0e3300000000000000000000000000000000000000000000000000000000664f0253000000000000000000000000000000000000000000000000000000006652f667000000000000000000000000000000000000000000000000000000006656e01f00000000000000000000000000000000000000000000000000000000665ad16f00000000000000000000000000000000000000000000000000000000665e2b1b0000000000000000000000000000000000000000000000000000000066606083000000000000000000000000000000000000000000000000000000006662b44b000000000000000000000000000000000000000000000000000000006665fdbf000000000000000000000000000000000000000000000000000000006669f23f00000000000000000000000000000000000000000000000000000000666de6bf000000000000000000000000000000000000000000000000000000006671db3f000000000000000000000000000000000000000000000000000000006675cfbf000000000000000000000000000000000000000000000000000000006679c43f00000000000000000000000000000000000000000000000000000000667db8bf000000000000000000000000000000000000000000000000000000006681ad3f000000000000000000000000000000000000000000000000000000006685a1bf000000000000000000000000000000000000000000000000000000006689963f00000000000000000000000000000000000000000000000000000000668d8abf0000000000000000000000000000000000000000000000000000000066917f3f00000000000000000000000000000000000000000000000000000000669573bf000000000000000000000000000000000000000000000000000000006699683f00000000000000000000000000000000000000000000000000000000669d5cbf0000000000000000000000000000000000000000000000000000000066a1513f0000000000000000000000000000000000000000000000000000000066a545bf0000000000000000000000000000000000000000000000000000000066a93a3f00000000000000000000000000000000000000000000000000000000