signMessage
signMessage
supports signing messages from the MagicSigner
.
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 signedMessage = await magicSigner.signMessage("test");
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<Hex>
A Promise
containing the signature of the message.