redpacket_v1_proxy_deploy.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // We require the Hardhat Runtime Environment explicitly here. This is optional
  2. // but useful for running the script in a standalone fashion through `node <script>`.
  3. //
  4. // When running the script with `npx hardhat run <script>` you'll find the Hardhat
  5. // Runtime Environment's members available in the global scope.
  6. const { ethers, upgrades } = require("hardhat");
  7. const deployedContracts = {
  8. mainnet: '',
  9. ropsten: '',
  10. bsc_mainnet: '',
  11. matic_mainnet: '',
  12. arbitrum: '',
  13. arbitrum_rinkeby: '0x4B20EbcFD9a74f969a77B9233a881FC5266930E1',
  14. xdai: '',
  15. goerli: '',
  16. fantom: '',
  17. avalanche: '',
  18. celo: '',
  19. optimism: '',
  20. optimism_kovan: '',
  21. aurora: '',
  22. fuse: '',
  23. boba: '',
  24. moonriver: '',
  25. }
  26. // deploy, we normally do this only once
  27. const firstDeployed = false;
  28. async function main() {
  29. let proxyAddress = deployedContracts['arbitrum_rinkeby']
  30. console.log("proxyAddress", proxyAddress)
  31. if (firstDeployed) {
  32. const HappyRedPacketImpl = await ethers.getContractFactory("HappyRedPacket");
  33. const HappyRedPacketProxy = await upgrades.deployProxy(HappyRedPacketImpl, []);
  34. await HappyRedPacketProxy.deployed()
  35. console.log("HappyRedPacketProxy deployed to:", HappyRedPacketProxy.address);
  36. } else {
  37. // upgrade contract
  38. const HappyRedPacketImpl = await ethers.getContractFactory('HappyRedPacket')
  39. const instance = await upgrades.upgradeProxy(proxyAddress, HappyRedPacketImpl)
  40. console.log("HappyRedPacketProxy upgradeProxy deployed to:", proxyAddress);
  41. }
  42. }
  43. // We recommend this pattern to be able to use async/await everywhere
  44. // and properly handle errors.
  45. main()
  46. .then(() => process.exit(0))
  47. .catch((error) => {
  48. console.error(error);
  49. process.exit(1);
  50. });