signMessage
signMessage
supports signing messages from the PortalSigner
.
This method must be called after authenticate
. Otherwise, this method will throw an error with the message Not Authenticated
.
Usage
ts
import { createPortalSigner } from "./portal";
const portalSigner = await createPortalSigner();
const signedMessage = await portalSigner.signMessage("test");
ts
import { sepolia } from "@alchemy/aa-core";
import { PortalSigner } from "@alchemy/aa-signers/portal";
export const createPortalSigner = async () => {
const portalSigner = new PortalSigner({
autoApprove: true,
gatewayConfig: `${sepolia.rpcUrls.alchemy.http}/${process.env.ALCHEMY_API_KEY}`,
chainId: sepolia.id,
});
await portalSigner.authenticate();
return portalSigner;
};
Returns
Promise<Hex>
A Promise
containing the signature of the message.