Created
January 27, 2022 23:06
-
-
Save emilianobilli/f611cedc1fe97c73ef06d986f4bda69f to your computer and use it in GitHub Desktop.
This file contains 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
const ethers = require('ethers'); | |
class Signature { | |
constructor(ethereum) { | |
this.ethereum = ethereum; | |
} | |
provider() { | |
return new ethers.providers.Web3Provider(this.ethereum); | |
} | |
signer() { | |
return this.provider().getSigner(); | |
} | |
async sign(message) { | |
const wallet = await this.signer(); | |
const address = await wallet.getAddress(); | |
const signature = await wallet.signMessage(message + ':' + address); | |
} | |
} | |
window.Signature = Signature; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment