Phantom Adapter
@web3auth/phantom-adapter
Phantom adapter allows you to connect with phantom wallet. You can read more about phantom wallet here.(https://docs.phantom.app/).
Basic Details
Adapter Name: phantom
Package Name: @web3auth/phantom-adapter
authMode: DAPP
chainNamespace: SOLANA
Default: YES
Installation
- npm
- Yarn
- pnpm
npm install --save @web3auth/phantom-adapter
yarn add @web3auth/phantom-adapter
pnpm add @web3auth/phantom-adapter
Arguments
- Table
- Interface
Parameter | type |
---|---|
chainConfig | CustomChainConfig |
clientId? | string |
sessionTime? | number |
web3AuthNetwork? | WEB3AUTH_NETWORK_TYPE |
interface PhantomAdapterOptions {
chainConfig?: CustomChainConfig;
clientId?: string;
sessionTime?: number;
web3AuthNetwork?: WEB3AUTH_NETWORK_TYPE;
}
Custom Chain Config
chainConfig
warning
While you can pass your chainConfig
, it is not required since you can directly pass it over to the
Web3Auth
/ Web3AuthNoModal
configuration while instantiating it.
Read more about it in their respective sections:
warning
If you do pass chainConfig
in an Adapter, it overwrites the chainConfig
passed over to the
Web3Auth
/ Web3AuthNoModal
constructor.
Change Adapter Settings
You can change the adapter settings by calling the setAdapterSettings()
function on the adapter
instance.
Arguments
- Table
- Interface
Parameter | type |
---|---|
clientId? | string |
sessionTime? | number |
chainConfig? | CustomChainConfig |
web3AuthNetwork? | WEB3AUTH_NETWORK_TYPE |
interface BaseAdapterSettings {
clientId?: string;
sessionTime?: number;
chainConfig?: CustomChainConfig;
web3AuthNetwork?: WEB3AUTH_NETWORK_TYPE;
}
Example
import { PhantomAdapter } from "@web3auth/phantom-adapter";
const phantomAdapter = new PhantomAdapter({
clientId,
sessionTime: 3600, // 1 hour in seconds
web3AuthNetwork: "sapphire_mainnet",
chainConfig: {
chainNamespace: CHAIN_NAMESPACES.SOLANA,
chainId: "0x1",
rpcTarget: "https://rpc.ankr.com/solana", // This is the public RPC we have added, please pass on your own endpoint while creating an app
},
});
web3auth.configureAdapter(phantomAdapter);
// You can also change the adapter settings by calling the setAdapterSettings() function on the adapter instance.
phantomAdapter.setAdapterSettings({
sessionTime: 86400, // 1 day in seconds
chainConfig: {
chainNamespace: CHAIN_NAMESPACES.SOLANA,
chainId: "0x1",
rpcTarget: "https://rpc.ankr.com/solana", // This is the public RPC we have added, please pass on your own endpoint while creating an app
},
web3AuthNetwork: "sapphire_mainnet",
});