Skip to content

Instantly share code, notes, and snippets.

@o-az
Created December 16, 2021 09:22
Show Gist options
  • Save o-az/ec35f85643dc83cc8e7bc26841f5435c to your computer and use it in GitHub Desktop.
Save o-az/ec35f85643dc83cc8e7bc26841f5435c to your computer and use it in GitHub Desktop.
declare const window: any
// account is the ethereum address
export const signMessage = async (account: string, message: string) => {
const { ethereum } = window
if (!ethereum) return
try {
const signature = await window.ethereum.request({
method: 'personal_sign',
params: [account, message],
})
return signature
} catch (error) {
console.error(error)
throw new Error(error as string)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment