diff --git a/deploys/localhost.json b/deploys/localhost.json index 0b0aeb9..d5dc604 100644 --- a/deploys/localhost.json +++ b/deploys/localhost.json @@ -3,6 +3,6 @@ "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" ], - "p2pix": "0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29", - "token": "0xD38D6367f452D097ccBfDe4490b7de570B6A72Db" + "p2pix": "", + "token": "" } diff --git a/hardhat.config.ts b/hardhat.config.ts index 2b56aba..ab1093d 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -9,22 +9,19 @@ import "solidity-docgen"; dotenvConfig({ path: resolve(__dirname, "./.env") }); -const mnemonic: string | undefined = process.env.MNEMONIC; -if (!mnemonic) { - throw new Error("Please set your MNEMONIC in a .env file"); -} +// Default mnemonic used by Hardhat / Anvil for deterministic accounts. +// Lets `--network localhost` (and the default in-process `hardhat` net) +// run without a .env. Public networks still require a real MNEMONIC. +const DEFAULT_MNEMONIC = + "test test test test test test test test test test test junk"; -const alchemyApiKey: string | undefined = - process.env.ALCHEMY_API_KEY; -if (!alchemyApiKey) { - throw new Error( - "Please set your ALCHEMY_API_KEY in a .env file", - ); -} +const mnemonic: string = process.env.MNEMONIC ?? DEFAULT_MNEMONIC; +const alchemyApiKey: string | undefined = process.env.ALCHEMY_API_KEY; const chainIds = { // "{INSERT_NAME}": {INSERT_ID}, hardhat: 31337, + localhost: 31337, mainnet: 1, "eth-sepolia": 11155111, "polygon-mumbai": 80001, @@ -35,6 +32,11 @@ const chainIds = { function getChainConfig( chain: keyof typeof chainIds, ): NetworkUserConfig { + if (!alchemyApiKey) { + throw new Error( + `Please set ALCHEMY_API_KEY in a .env file before targeting ${chain}`, + ); + } let jsonRpcUrl = "https://" + chain + ".g.alchemy.com/v2/" + alchemyApiKey; return { // Comment out for default hardhat account settings @@ -82,6 +84,15 @@ const config: HardhatUserConfig = { }, chainId: chainIds.hardhat, }, + // External Anvil / Hardhat node (e.g. `anvil --port 8545`). Used by + // the frontend e2e suite to deploy a fresh chain per CI run. + localhost: { + url: "http://127.0.0.1:8545", + chainId: chainIds.localhost, + accounts: { + mnemonic, + }, + }, // network: getChainConfig("{INSERT_NAME}"), mainnet: getChainConfig("mainnet"), sepolia: getChainConfig("eth-sepolia"),