I can't get the value from the signer.getAddress()
function on Ethers.js.
When I try to use "alert" or "console.log" it is fine but I want to display it directly on the page. It says; "object Promise".
Here is my code:
import "./App.css";
import { ethers } from "ethers";
function App() {
const provider = new ethers.providers.Web3Provider(window.ethereum, "any");
const signer = provider.getSigner();
async function connectMetamask() {
await provider.send("eth_requestAccounts", []);
}
async function myAddress() {
await signer.getAddress();
}
return (
<div className="general">
<div className="web3-loader">
<button className="button1" onClick={connectMetamask}>
Connect Metamask
</button>
</div>
<br></br>
<div className="input-area">
<label>{"Your address is: " + myAddress()} </label>
<br></br>
<label>Recipient address:</label>
<input
type="text"
placeholder="Receiver address"
className="input2"
></input>
<br></br>
<label>Amount:</label>
<input
type="text"
placeholder="Amount of ETH"
className="input3"
></input>
</div>
</div>
);
}
export default App;