I am trying to get the ethereum address on phantom wallet but I can't find a way to do it, Here in my code I check first if phantom wallet is installed then get the solana addess but i need also to get the ethereum address.
const handlePhantom = async () => {
if (window.solana && window.solana.isPhantom) {
try {
await window.solana.connect();
const publicKey = window.solana.publicKey.toString();
const ethAddress = `0x${publicKey}`;
console.log(ethAddress);
if (!_.isNil(publicKey)) {
setUserInfo({
...userInfo,
walletAddress: publicKey.toLowerCase(),
});
setconnectButton(true);
setOpenConfirmChanges(true);
} else {
setAlert((prevState) => ({
...prevState,
type: 'error',
isShow: true,
content: 'No wallet account found!',
}));
setUserInfo({
...userInfo,
walletAddress: '',
});
setconnectButton(false);
}
} catch (error) {
setAlert((prevState) => ({
...prevState,
type: 'error',
isShow: true,
content: 'Please select your account wallet.',
}));
// Handle error connecting to the wallet
}
} else {
setAlert((prevState) => ({
...prevState,
type: 'error',
isShow: true,
content: 'Please install Phantom Wallet to your browser.',
}));
// Handle case where Phantom wallet is not installed or detected
}
};