-
-
Save Rami-Majdoub/c3d0e5da6af365517e8221de14f11f40 to your computer and use it in GitHub Desktop.
Requesting the public key from MetaMask
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
// Account is account address provided as string | |
// App must have access to the specified account | |
const account = "0x012...bc" | |
// Key is returned as base64 | |
const keyB64 = await window.ethereum.request({ | |
method: 'eth_getEncryptionPublicKey', | |
params: [account], | |
}) as string; | |
const publicKey = Buffer.from(keyB64, 'base64'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment