Skip to content

Instantly share code, notes, and snippets.

@emilianobilli
Created January 27, 2022 23:06
Show Gist options
  • Save emilianobilli/f611cedc1fe97c73ef06d986f4bda69f to your computer and use it in GitHub Desktop.
Save emilianobilli/f611cedc1fe97c73ef06d986f4bda69f to your computer and use it in GitHub Desktop.
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