Skip to content

Metamask #4

@stephune

Description

@stephune

// Get current chain ID
async function getCurrentChain() {
try {
const chainId = await ethereum.request({
method: "eth_chainId"
});
console.log("Current chain ID:", chainId);
return chainId;
} catch (err) {
console.error("Error getting chain:", err);
}
}

// Listen for network changes
ethereum.on("chainChanged", (chainId) => {
console.log("Network changed to:", chainId);
// We recommend reloading the page
window.location.reload();
});

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentationduplicateThis issue or pull request already existsenhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is neededinvalidThis doesn't seem rightquestionFurther information is requestedwontfixThis will not be worked on

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions