Skip to content

signMessage

signMessage supports signing messages from the FordefiSigner.

This method must be called after authenticate. Otherwise, this method will throw an error with the message Not Authenticated.

Usage

ts
import { createFordefiSigner } from "./fordefi";

const fordefiSigner = await createFordefiSigner();

const signedMessage = await fordefiSigner.signMessage("test");
ts
import { FordefiSigner } from "@alchemy/aa-signers/fordefi";
import { FordefiWeb3Provider } from "@fordefi/web3-provider";

const fordefi = new FordefiWeb3Provider({
  address: "0x1234567890123456789012345678901234567890",
  chainId: 11155111,
  apiUserToken: process.env.FORDEFI_API_USER_TOKEN!,
  apiPayloadSignKey: process.env.FORDEFI_API_PAYLOAD_SIGNING_KEY!,
});

export const createFordefiSigner = async () => {
  const fordefiSigner = new FordefiSigner(fordefi);

  await fordefiSigner.authenticate();

  return fordefiSigner;
};

Returns

Promise<Hex>

A Promise containing the signature of the message.

Parameters

msg: string | Uint8Array -- the message to sign