Skip to content

Instantly share code, notes, and snippets.

@andremedeiros
Created April 15, 2020 20:42
Show Gist options
  • Save andremedeiros/ece6a72a68f1410174e595525f12a5a2 to your computer and use it in GitHub Desktop.
Save andremedeiros/ece6a72a68f1410174e595525f12a5a2 to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="https://cdn.jsdelivr.net/gh/ethereum/[email protected]/dist/web3.js"></script>
<script src="https://cdn.ethers.io/scripts/ethers-v4.min.js"></script>
</head>
<body>
<script>
document.addEventListener("DOMContentLoaded", function () {
if (typeof window === 'undefined' || !window.ethereum) {
alert('noce dice')
throw new Error("no dice");
}
let web3 = null;
if (typeof window !== 'undefined' && window.ethereum) {
(async () => {
web3 = new Web3()
await ethereum.enable()
web3.setProvider(ethereum)
let accounts = await web3.eth.getAccounts()
alert(accounts)
var provider = new window.ethers.providers.Web3Provider(
web3.eth.currentProvider
);
alert('provider');
alert(provider);
var signer = provider.getSigner();
alert('signer');
alert(signer);
})()
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment