Adapters for Web3Auth PnP Web SDKs
Adapters are essentially connectors between Web3Auth and the underlying wallet provider. For example, an adapter for connecting with torus wallet is available under web3auth as @web3auth/torus-evm-adapter. Every adapter follows a common interface which is required by Web3Auth to communicate with the wallet.
An adapter emits certain events like CONNECTED
, CONNECTING
and DISCONNECTED
etc during login
lifecycle of a user. Each adapter exposes provider on successful user login that can be used to
invoke RPC calls on wallet and on connected blockchain.
Hence, adapters are needed to connect your Web3Auth instance to a wallet provider. Web3Auth by
default contains a pre-configured list of login adapters. It also provides flexibility to add/remove
adapters or to use some existing adapter with custom configurations. To configure an adapter create
an instance of the adapter by using its corresponding package and pass the returned adapter instance
in the configureAdapter
function.
For example, to configure auth adapter,
- Import the
AuthAdapter
from the@web3auth/auth-adapter
package. - Create an instance of the adapter along with the configuration
- Pass the returned instance to
web3auth.configureAdapter
as shown in the example below.
import { AuthAdapter } from "@web3auth/auth-adapter";
const authAdapter = new AuthAdapter({
adapterSettings: {
network: "sapphire_mainnet",
uxMode: "popup",
},
});
web3auth.configureAdapter(authAdapter);
Currently Available Wallet Adapters
By default Web3Auth's modal UI supports a set of default adapters depending on the authMode
being
used. By default, Web3Auth requires basic configuration client_id
, and registering a redirect if
you are using CustomAuth adapter from the dashboard.
The table below summarizes all the available adapters and their properties
Adapter | ChainNamespace | Default | Package Name |
---|---|---|---|
auth | EIP155 ,SOLANA | YES | @web3auth/auth-adapter |
torus-evm | EIP155 | NO | @web3auth/torus-evm-adapter |
torus-solana | SOLANA | No | @web3auth/torus-solana-adapter |
walletconnect-v2 | EIP155 | NO | @web3auth/wallet-connect-v2-adapter |
coinbase | EIP155 | NO | @web3auth/coinbase |
default-evm-adapter | EIP155 | NO | @web3auth/default-evm-adapter |
default-solana-adapter | SOLANA | NO | @web3auth/default-solana-adapter |
Common Configuration Interfaces
type CustomChainConfig = {
chainNamespace: ChainNamespaceType;
/**
* The chain id of the chain
*/
chainId: string;
/**
* RPC target Url for the chain
*/
rpcTarget: string;
/**
* Display Name for the chain
*/
displayName: string;
/**
* Url of the block explorer
*/
blockExplorerUrl: string;
/**
* Default currency ticker of the network (e.g: ETH)
*/
ticker: string;
/**
* Name for currency ticker (e.g: `Ethereum`)
*/
tickerName: string;
/**
* Logo of the chain
*/
logo: stirng;
};
If you do pass chainConfig
in an Adapter, it overwrites the chainConfig
passed over to the
Web3Auth
/ Web3AuthNoModal
constructor.