Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions script of dapp
Original file line number Diff line number Diff line change
@@ -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);