You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.5 KiB

1 year ago
  1. import { ethers, upgrades } from "hardhat";
  2. async function main() {
  3. // console.log("開始部署FIL合約");
  4. // const FIL = await ethers.getContractFactory("FIL");
  5. // const fil = await FIL.deploy();
  6. // console.log("FIL合約", fil.target);
  7. const FIL_ADDRESS = process.env.FIL_ADDRESS
  8. // const FIL_ADDRESS = fil.target
  9. console.log('fil地址:',FIL_ADDRESS);
  10. console.log("開始部署NFT合約");
  11. const NFT = await ethers.getContractFactory("NFT");
  12. const nft = await NFT.deploy("MyNFT", "MNFT");
  13. console.log("NFT合約", nft.target);
  14. console.log("開始部署Pool合約");
  15. const Pool = await ethers.getContractFactory("Pool");
  16. const pool = await upgrades.deployProxy(Pool,[FIL_ADDRESS,nft.target],{ initializer: "initialize" });
  17. console.log("Pool合約", pool.target);
  18. console.log("開始部署Pledge合約");
  19. const Pledge = await ethers.getContractFactory("Pledge");
  20. const pledge = await upgrades.deployProxy(
  21. Pledge,
  22. [nft.target,pool.target],
  23. { initializer: "initialize" }
  24. );
  25. console.log("Pledge合約", pledge.target);
  26. console.log('執行初始化設置合約地址');
  27. const tx = await nft.setPledgeAddress(pledge.target);
  28. await tx.wait()
  29. const tx1 = await pool.setPledgeContractAddress(pledge.target);
  30. await tx1.wait()
  31. // 測試使用
  32. console.log('設置成功');
  33. console.log('NFT的質押合約地址',await nft.pledgeAddress());
  34. console.log('Pool的質押合約地址',await pool._pledgeContractAddress());
  35. console.log('质押时间',await pledge.dayTime());
  36. }
  37. async function mainUpgradeProxy() {
  38. // 3.1173
  39. const poolAddress = "";
  40. const pledgeAddress = "0xD8553004442098415734A9EFE49e13E29919BfF9";
  41. // const Pool = await ethers.getContractFactory("Pool");
  42. // const pool = await upgrades.upgradeProxy(poolAddress, Pool);
  43. console.log('開始升級');
  44. const Pledge = await ethers.getContractFactory("Pledge");
  45. const pledge = await upgrades.upgradeProxy(pledgeAddress, Pledge);
  46. console.log('升級成功');
  47. // console.log("Pool合約", pool.address);
  48. console.log("Pledge合約", pledge.target);
  49. }
  50. // We recommend this pattern to be able to use async/await everywhere
  51. // and properly handle errors.
  52. main().catch((error) => {
  53. console.error(error);
  54. process.exitCode = 1;
  55. });
  56. // npx hardhat verify --network bscTest 0x8F7d8242d1A60f177e7389Bad8A7680FA50f2B89
  57. // FIL合約 0x8F7d8242d1A60f177e7389Bad8A7680FA50f2B89
  58. // NFT合約 0x8A50bd742312610b446286F43DF0DfB963f5fED5
  59. // Pool合約 0x36821f56980814932530929C12dFC5fE80b50603
  60. // Pledge合約 0x0d8e6b56FECEA32632a1B0fE73a84D4c5A2D44be