Skip to content

Commit

Permalink
fix eth_accounts calls on localNetwork (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 authored Jul 27, 2023
1 parent 6370b4c commit 03d4c34
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 6 additions & 5 deletions packages/nextjs/components/scaffold-eth/Faucet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import { notification } from "~~/utils/scaffold-eth";
// Account index to use from generated hardhat accounts.
const FAUCET_ACCOUNT_INDEX = 0;

const localWalletClient = createWalletClient({
chain: hardhat,
transport: http(),
});

/**
* Faucet modal which lets you send ETH to any address.
*/
Expand All @@ -23,10 +28,6 @@ export const Faucet = () => {
const { chain: ConnectedChain } = useNetwork();
const isMounted = useIsMounted();

const localWalletClient = createWalletClient({
chain: hardhat,
transport: http(),
});
const faucetTxn = useTransactor(localWalletClient);

useEffect(() => {
Expand All @@ -51,7 +52,7 @@ export const Faucet = () => {
}
};
getFaucetAddress();
}, [localWalletClient]);
}, []);

const sendETH = async () => {
if (!faucetAddress) {
Expand Down
10 changes: 6 additions & 4 deletions packages/nextjs/components/scaffold-eth/FaucetButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import { useAccountBalance, useTransactor } from "~~/hooks/scaffold-eth";
const NUM_OF_ETH = "1";
const FAUCET_ADDRESS = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266";

const localWalletClient = createWalletClient({
chain: hardhat,
transport: http(),
});

/**
* FaucetButton button which lets you grab eth.
*/
Expand All @@ -21,10 +26,7 @@ export const FaucetButton = () => {
const isMounted = useIsMounted();

const [loading, setLoading] = useState(false);
const localWalletClient = createWalletClient({
chain: hardhat,
transport: http(),
});

const faucetTxn = useTransactor(localWalletClient);

const sendETH = async () => {
Expand Down

0 comments on commit 03d4c34

Please sign in to comment.