web3 = new Web3(web3.currentProvider);
account = await web3.eth.getAccounts();
these code bring me metamask account address. In this situation, how can i get my metamask account's public key??? (on javascript code)
if (window.ethereum) {
try {
const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' })
const account = accounts[0]
const publicKey = await window.ethereum.request({
method: 'eth_getEncryptionPublicKey',
params: [account],
})
} catch (error) {
console.log({ error })
}
}
Note: accounts is your metamask wallet address publicKey is your accounts public key
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With