Skip to content

Instantly share code, notes, and snippets.

@Breta01
Last active March 17, 2022 05:15
Show Gist options
  • Save Breta01/ade58af818318424b1a6152b117687a6 to your computer and use it in GitHub Desktop.
Save Breta01/ade58af818318424b1a6152b117687a6 to your computer and use it in GitHub Desktop.
Requesting the public key from MetaMask
// 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