Coinbase Adapter
@web3auth/coinbase-adapter
Coinbase adapter allows you to connect with coinbase wallet. You can read more about coinbase wallet here.(https://docs.cloud.coinbase.com/wallet-sdk/docs).
Basic Details
Adapter Name: coinbase
Package Name: @web3auth/coinbase-adapter
authMode: DAPP
chainNamespace: EIP155
Default: YES
Installation
- npm
- Yarn
- pnpm
npm install --save @web3auth/coinbase-adapter
yarn add @web3auth/coinbase-adapter
pnpm add @web3auth/coinbase-adapter
Arguments
- Table
- Interface
Parameter | type |
---|---|
chainConfig? | CustomChainConfig |
adapterSettings? | CoinbaseWalletSDKOptions |
clientId? | string |
sessionTime? | number |
web3AuthNetwork? | WEB3AUTH_NETWORK_TYPE |
interface CoinbaseAdapterOptions {
chainConfig?: CustomChainConfig;
adapterSettings?: CoinbaseWalletSDKOptions;
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.
CoinbaseWalletSDKOptions
Checkout the Coinbase Wallet SDK Documentation for these options.
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 { CoinbaseAdapter } from "@web3auth/coinbase-adapter";
const coinbaseAdapter = new CoinbaseAdapter({
clientId:
"BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ",
sessionTime: 3600, // 1 hour in seconds
chainConfig: {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: "0x1",
rpcTarget: "https://rpc.ankr.com/eth", // This is the public RPC we have added, please pass on your own endpoint while creating an app
},
web3AuthNetwork: "sapphire_mainnet",
});
web3auth.configureAdapter(coinbaseAdapter);
// You can also change the adapter settings later on
coinbaseAdapter.setAdapterSettings({
sessionTime: 86400, // 1 day in seconds
chainConfig: {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: "0x1",
rpcTarget: "https://rpc.ankr.com/eth", // This is the public RPC we have added, please pass on your own endpoint while creating an app
},
web3AuthNetwork: "sapphire_mainnet",
});