getAddress
getAddress
returns the EOA address of the Signer.
This method must be called after authenticate
. Otherwise, this method will throw an error with the message Not Authenticated
.
Usage
ts
import { createMagicSigner } from "./magic";
const magicSigner = await createMagicSigner();
const address = await magicSigner.getAddress();
ts
import { MagicSigner } from "@alchemy/aa-signers/magic";
// this is generated from the [Magic Dashboard](https://dashboard.magic.link/)
const MAGIC_API_KEY = "pk_live_...";
export const createMagicSigner = async () => {
const magicSigner = new MagicSigner({ apiKey: MAGIC_API_KEY });
await magicSigner.authenticate({
authenticate: async () => {
await magicSigner.inner.wallet.connectWithUI();
},
});
return magicSigner;
};
Returns
Promise<Address>
A Promise
containing the address of the Signer.