Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Script] Add script to request deployment and verify contract #29

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions scripts/requestDeployment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { BytesLike } from "ethers";
import { ethers } from "hardhat";
import { time } from "@nomicfoundation/hardhat-network-helpers";
async function main() {
let poolStartTime = 1720229672;
let poolEndTime = poolStartTime + 120;
let unstakeLockUp = poolStartTime + 10;
let claimLockUp = poolStartTime + 10;

const data = {
stakeToken: "0xAfe9448d1C50F1cb3697b50EbDB956C8C73e0A7a",
rewardToken: "0xA854C1bC1aEcC80094E2ac3C0EE98581460F1caD",
poolStartTime: poolStartTime,
poolEndTime: poolEndTime,
unstakeLockUpTime: unstakeLockUp,
claimLockUpTime: claimLockUp,
rewardPerSecond: 1
}
let factory = await ethers.getContractAt("ERC20LockUpStakingFactory", "0xa5Ffec47E75a69E5EE8480150372e6D7754b1A9D"/**Contract Address */);
await factory.requestDeployment(ethers.randomBytes(32), data)
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
51 changes: 51 additions & 0 deletions scripts/verifyContract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { ethers, run, network } from "hardhat";
import config from "../hardhat.config"; // Your Hardhat config file

async function main() {
const contractAddress = "0x2CB4a3e461d6cE5f3A80B28Bb8596c734E267c26"; // Replace with your deployed address
const contractName = "ERC20LockUpPool";

// Ensure the contract is already deployed on the target network
const deployedCode = await ethers.provider.getCode(contractAddress);
if (deployedCode === "0x") {
throw new Error(
`Contract not deployed at address: ${contractAddress} on network: ${network.name}`
);
}

const poolStartTime = 1720229672;
const poolEndTime = poolStartTime + 120;
const unstakeLockUp = poolStartTime + 10;
const claimLockUp = poolStartTime + 10;
const rewardPerSecond = 1;

// Verify on Etherscan
try {
await run("verify:verify", {
address: contractAddress,
constructorArguments: [
"0xAfe9448d1C50F1cb3697b50EbDB956C8C73e0A7a", // stakeToken
"0xA854C1bC1aEcC80094E2ac3C0EE98581460F1caD", // rewardToken
poolStartTime,
poolEndTime,
unstakeLockUp,
claimLockUp,
rewardPerSecond,
], // Add constructor arguments
contract: `contracts/pools/ERC20LockUpStakingPool.sol:ERC20LockUpPool`, // Path from Hardhat root
});

console.log("Contract verified successfully!");
} catch (error) {
if ((error as Error).message.includes("Contract source code already verified")) {
console.log("Contract already verified");
} else {
console.error("Error verifying contract:", error);
}
}
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
Loading