Using the Signer as an EOA
Because the Alchemy Signer has its own address
and supports signing messages as raw hashes, it is possible to use this signer as an EOA directly. To do so, you can adapt the AlchemySigner to your library of choice and leverage its signMessage
, signTypedData
, and signTransaction
methods directly. The public address of the signer can be accessed via getAddress
.
If you are using viem, then you can use the toViemAccount
method which will allow you to use the signer with a WalletClient
.
createWalletClient.ts
import { signer } from "./signer";
import { createWalletClient, http } from "viem";
import { sepolia } from "viem/chains";
export const walletClient = createWalletClient({
transport: http("alchemy_rpc_url"),
chain: sepolia,
account: signer.toViemAccount(),
});