Web3auth Signer
Web3AuthSigner
is a signer implementation which extends SmartAccountAuthenticator
to leverage the web3auth web modal SDK. It supports features such as authentication, message and typed data signing, and authentication details retrieval.
Web3AuthSigner
provides implementations for all methods on SmartAccountAuthenticator
:
authenticate
-- supports user authentication.getAddress
-- gets the address of the smart contract account's connected EOA signer account.signMessage
-- supports message signatures.signTypedData
-- supports typed data signatures.getAuthDetails
-- supports authentication details retrieval.
Install Dependencies
Web3AuthSigner
requires installation of the @web3auth/modal
and @web3auth/base
SDKs. aa-signers
lists them as optional dependencies.
bash
npm i -s @web3auth/modal
npm i -s @web3auth/base
bash
yarn add @web3auth/modal
yarn add @web3auth/base
Usage
ts
import { createWeb3AuthSigner } from "./web3auth";
const web3AuthSigner = await createWeb3AuthSigner();
const address = await web3AuthSigner.getAddress();
const details = await web3AuthSigner.getAuthDetails();
const signedMessage = await web3AuthSigner.signMessage("test");
const typedData = {
types: {
Request: [{ name: "hello", type: "string" }],
},
primaryType: "Request",
message: {
hello: "world",
},
};
const signTypedData = await web3AuthSigner.signTypedData(typedData);
ts
import { Web3AuthSigner } from "@alchemy/aa-signers/web3auth";
export const createWeb3AuthSigner = async () => {
const web3AuthSigner = new Web3AuthSigner({
clientId: "test",
chainConfig: {
chainNamespace: "eip155",
},
});
await web3AuthSigner.authenticate({
init: async () => {
await web3AuthSigner.inner.initModal();
},
connect: async () => {
await web3AuthSigner.inner.connect();
},
});
return web3AuthSigner;
};