mirror of
https://github.com/luxfhe/example-dapps.git
synced 2026-10-30 18:13:32 +00:00
54 lines
2.2 KiB
TypeScript
54 lines
2.2 KiB
TypeScript
import * as chains from "viem/chains";
|
|
|
|
export type BaseConfig = {
|
|
targetNetworks: readonly chains.Chain[];
|
|
pollingInterval: number;
|
|
alchemyApiKey: string;
|
|
rpcOverrides?: Record<number, string>;
|
|
walletConnectProjectId: string;
|
|
onlyLocalBurnerWallet: boolean;
|
|
};
|
|
|
|
export type ScaffoldConfig = BaseConfig;
|
|
|
|
const rawAlchemyKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY;
|
|
if (!rawAlchemyKey) {
|
|
if (process.env.NODE_ENV === "production") {
|
|
throw new Error("Environment variable NEXT_PUBLIC_ALCHEMY_API_KEY is required in production.");
|
|
} else {
|
|
// eslint-disable-next-line no-console
|
|
console.warn("NEXT_PUBLIC_ALCHEMY_API_KEY is not set. Falling back to public RPCs.");
|
|
}
|
|
}
|
|
|
|
const isProduction = process.env.NODE_ENV === "production";
|
|
const baseTargets = [chains.sepolia] as const;
|
|
// Sepolia first, then hardhat (so Sepolia is default and hardhat is optional)
|
|
const targetNetworks = (isProduction ? baseTargets : ([...baseTargets, chains.hardhat] as const));
|
|
|
|
const scaffoldConfig = {
|
|
// The networks on which your DApp is live
|
|
targetNetworks,
|
|
// The interval at which your front-end polls the RPC servers for new data (it has no effect if you only target the local network (default is 4000))
|
|
pollingInterval: 30000,
|
|
// This is ours Alchemy's default API key.
|
|
// You can get your own at https://dashboard.alchemyapi.io
|
|
// It's recommended to store it in an env variable:
|
|
// .env.local for local testing, and in the Vercel/system env config for live apps.
|
|
alchemyApiKey: rawAlchemyKey || "",
|
|
// If you want to use a different RPC for a specific network, you can add it here.
|
|
// The key is the chain ID, and the value is the HTTP RPC URL
|
|
rpcOverrides: {
|
|
// Example:
|
|
// [chains.mainnet.id]: "https://mainnet.rpc.buidlguidl.com",
|
|
},
|
|
// This is ours WalletConnect's default project ID.
|
|
// You can get your own at https://cloud.walletconnect.com
|
|
// It's recommended to store it in an env variable:
|
|
// .env.local for local testing, and in the Vercel/system env config for live apps.
|
|
walletConnectProjectId: process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID || "3a8170812b534d0ff9d794f19a901d64",
|
|
onlyLocalBurnerWallet: true,
|
|
} as const satisfies ScaffoldConfig;
|
|
|
|
export default scaffoldConfig;
|