Skip to content

Commit

Permalink
chore: move default alchemy api key to the variable
Browse files Browse the repository at this point in the history
  • Loading branch information
rin-st committed Dec 10, 2024
1 parent d44e3a4 commit cc61e94
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/nextjs/scaffold.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export type ScaffoldConfig = {
onlyLocalBurnerWallet: boolean;
};

export const DEFAULT_ALCHEMY_API_KEY = "oKxs-03sij-U_N0iOlrSsZFr29-IqbuF";

const scaffoldConfig = {
// The networks on which your DApp is live
targetNetworks: [chains.hardhat],
Expand All @@ -20,7 +22,7 @@ const scaffoldConfig = {
// 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: process.env.NEXT_PUBLIC_ALCHEMY_API_KEY || "oKxs-03sij-U_N0iOlrSsZFr29-IqbuF",
alchemyApiKey: process.env.NEXT_PUBLIC_ALCHEMY_API_KEY || DEFAULT_ALCHEMY_API_KEY,

// This is ours WalletConnect's default project ID.
// You can get your own at https://cloud.walletconnect.com
Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs/services/web3/wagmiConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { wagmiConnectors } from "./wagmiConnectors";
import { Chain, createClient, fallback, http } from "viem";
import { hardhat, mainnet } from "viem/chains";
import { createConfig } from "wagmi";
import scaffoldConfig from "~~/scaffold.config";
import scaffoldConfig, { DEFAULT_ALCHEMY_API_KEY } from "~~/scaffold.config";
import { getAlchemyHttpUrl } from "~~/utils/scaffold-eth";

const { targetNetworks } = scaffoldConfig;
Expand All @@ -21,7 +21,7 @@ export const wagmiConfig = createConfig({

const alchemyHttpUrl = getAlchemyHttpUrl(chain.id);
if (alchemyHttpUrl) {
const isUsingDefaultKey = scaffoldConfig.alchemyApiKey === "oKxs-03sij-U_N0iOlrSsZFr29-IqbuF";
const isUsingDefaultKey = scaffoldConfig.alchemyApiKey === DEFAULT_ALCHEMY_API_KEY;
// If using default Scaffold-ETH 2 API key, we prioritize the default RPC
rpcFallbacks = isUsingDefaultKey ? [http(), http(alchemyHttpUrl)] : [http(alchemyHttpUrl), http()];
}
Expand Down

0 comments on commit cc61e94

Please sign in to comment.