Last active
March 17, 2022 05:15
-
-
Save Breta01/ade58af818318424b1a6152b117687a6 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