hardhat.config.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { HardhatUserConfig, extendEnvironment } from "hardhat/config";
  2. import "@nomicfoundation/hardhat-toolbox";
  3. import deployer from './.secret'
  4. import logger from './utils/logger'
  5. import debug from './utils/debug'
  6. import {HardhatRuntimeEnvironment} from "hardhat/types";
  7. const ETH_RPC = 'http://3.227.34.41:8545'
  8. const ETH_W_RPC = 'http://3.227.34.41:18545'
  9. const ETH_W_WS = 'ws://3.227.34.41:18546'
  10. const ETH_W_IPC = '/ethereum_pow_800/data/geth.ipc'
  11. const config: HardhatUserConfig = {
  12. defaultNetwork: 'eth_w',
  13. solidity: "0.7.6",
  14. networks: {
  15. eth: {
  16. url: ETH_RPC,
  17. chainId: 1,
  18. accounts: [deployer.private]
  19. },
  20. eth_w: {
  21. url: ETH_W_RPC,
  22. chainId: 10001,
  23. accounts: [deployer.private]
  24. }
  25. },
  26. paths: {
  27. sources: "./contracts",
  28. tests: "./test",
  29. cache: "./cache",
  30. artifacts: "./artifacts"
  31. },
  32. mocha: {
  33. timeout: 40000
  34. }
  35. };
  36. extendEnvironment((hre: HardhatRuntimeEnvironment) => {
  37. const Web3 = require('web3');
  38. hre.Web3 = Web3;
  39. logger.debug(`is ${debug.isDev() ? 'dev' : 'pro'} model.`)
  40. if (debug.isDev()) {
  41. logger.debug(`use ${ETH_W_WS}`)
  42. hre.web3 = new Web3(ETH_W_WS);
  43. } else {
  44. const net = require('net');
  45. logger.debug(`use ${ETH_W_IPC}`)
  46. hre.web3 = new Web3(ETH_W_IPC, net);
  47. }
  48. })
  49. export default config;