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.

81 lines
2.8 KiB

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