Web3Auth
Learn how to use Web3Auth with account abstraction.
If you are using Web3Auth to sign transactions, you will need to configure a Web3Auth provider and get the signer from this provider.
Configuring Web3Auth
First, see how to configure Web3Auth at Web3Auth Quickstart.
Live Tutorial
You can see a tutorial using Web3Auth here: Web3Auth Demo.
Integration
Here is an example that uses an Openlogin adapter.
import { Web3Auth } from "@web3auth/modal";
import { OpenloginAdapter } from "@web3auth/openlogin-adapter";
const chainConfig = {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: "0x1",
rpcTarget: "https://api.stackup.sh/v1/node/API_KEY",
displayName: "Ethereum Mainnet",
blockExplorer: "https://etherscan.io",
ticker: "ETH",
tickerName: "Ethereum",
};
const web3auth = new Web3AuthNoModal({...});
const privateKeyProvider = new EthereumPrivateKeyProvider({
config: { chainConfig },
});
const openloginAdapter = new OpenloginAdapter({
privateKeyProvider,
adapterSettings: {...},
mfaSettings: {...},
loginSettings: {...},
});
web3auth.configureAdapter(openloginAdapter);
const web3authProvider = await web3auth.connectTo(
WALLET_ADAPTERS.OPENLOGIN,
{
loginProvider: "google",
}
);
// Initialize builder with Web3Auth signer
const signer = web3authProvider.getSigner();
var builder = await Presets.Builder.SimpleAccount.init(signer, rpcUrl);
const address = builder.getSender();
console.log(Account address: ${address});
Updated 8 months ago