create-env.js 831 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * This script is used to generate the .env file for a specific network.
  3. * You can call it like this:
  4. * node create-env.js <chain-id>
  5. */
  6. const { DefaultStore, EvmChain } = require("contract_manager");
  7. const { writeFileSync } = require("fs");
  8. async function main() {
  9. const chainId = process.argv[2];
  10. const chain = DefaultStore.chains[chainId];
  11. if (!chain) {
  12. throw new Error(`Chain ${chainId} not found`);
  13. }
  14. if (!(chain instanceof EvmChain)) {
  15. throw new Error(`${chainId} is not an EVM chain`);
  16. }
  17. writeFileSync(
  18. `.env`,
  19. `MIGRATIONS_DIR=./migrations/prod-receiver\n` +
  20. `MIGRATIONS_NETWORK=${chain.getId()}\n` +
  21. `VALID_TIME_PERIOD_SECONDS=60\n` +
  22. `SINGLE_UPDATE_FEE_IN_WEI=1\n` +
  23. `NETWORK_ID=${chain.networkId}\n` +
  24. `RPC_URL=${chain.getRpcUrl()}\n`
  25. );
  26. }
  27. main();