diff --git a/script of dapp b/script of dapp new file mode 100644 index 00000000..6981f38a --- /dev/null +++ b/script of dapp @@ -0,0 +1,15 @@ +async function connect() { + if (!window.ethereum) { + alert("MetaMask is required to use this demo."); + return; + } + + const provider = new ethers.BrowserProvider(window.ethereum); + const accounts = await provider.send("eth_requestAccounts", []); + const network = await provider.getNetwork(); + + document.getElementById("status").innerText = + `Connected: ${accounts[0]} on ${network.name}`; +} + +document.getElementById("connect").addEventListener("click", connect);