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.

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