Created
October 10, 2022 13:49
-
-
Save starlabman/373442ae4453db90bc0266c2eae5b377 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Connect to crypto wallet</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/web3/1.7.4-rc.1/web3.min.js"></script> | |
</head> | |
<body> | |
<script> | |
/* To connect using MetaMask */ | |
async function connect() { | |
if (window.ethereum) { | |
await window.ethereum.request({ method: "eth_requestAccounts" }); | |
window.web3 = new Web3(window.ethereum); | |
const account = web3.eth.accounts; | |
//Get the current MetaMask selected/active wallet | |
const walletAddress = account.givenProvider.selectedAddress; | |
console.log(`Wallet: ${walletAddress}`); | |
} else { | |
console.log("No wallet"); | |
} | |
} | |
</script> | |
<input type="button" value="Connect Wallet" onclick="connect();" /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Web3 Metamask Login Version 2 https://github.com/starlabman/Web3-Metamask-Login
I am an application developer, I do back-end and front-end programming, and server configuration and management. I hesitate to say "full stack developer", a term popularized some time ago, which has become controversial.