Fund & Withdraw Front-end Ready

This commit is contained in:
hoelee 2024-08-07 08:50:52 +08:00
parent 70a2714570
commit a9311b04f6
3 changed files with 10 additions and 2 deletions

View File

@ -21,5 +21,8 @@ Test localhost hardhat node
* RPC URL from VS code: http://127.0.0.1:8545/
* Default Hardhat node Chain ID from VS code: 31337
* Currency Symbol ETH (Or Any)
* Metamark add account via private key
* MetaMark add account via private key
* Connect With the added account
* MetaMask Prompt Error - Reset account
* Due to localhost hardhat node restarted, nonce start from 0 again

View File

@ -3,7 +3,6 @@
<head>
<title>Fund Me App</title>
</head>
<body>
<button id="connectButton">Connect</button>
<button id="balanceButton">getBalance</button>

View File

@ -48,6 +48,12 @@ async function fund() {
const ethAmount = document.getElementById("ethAmount").value;
console.log(`Funding with ${ethAmount}...`);
if (typeof window.ethereum !== "undefined") {
/* Need:
provider / connection to the blockchain
signer / wallet / someone with gas
contract that we are interacting with
ABI & address
*/
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const contract = new ethers.Contract(contractAddress, abi, signer);