Created
December 16, 2021 09:22
-
-
Save o-az/ec35f85643dc83cc8e7bc26841f5435c 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
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