Namespace: wallet
Functions
autoSwitchNetwork
▸ autoSwitchNetwork(callbacks?
, force?
): Promise
<void
>
If non-default network is connected and if auto-switch is configured globally or requested by "force" parameter, switch wallet to the default network
Parameters
Name | Type | Default value | Description |
---|---|---|---|
callbacks? | IGenericTransactionCallbacks | undefined | - |
force | boolean | false | True to force switching to the default network |
Returns
Promise
<void
>
Throws
Unsupported network error if the user is on incorrect network, and neither global settings nor the parameter requires the switch
Defined in
connect
▸ connect(): Promise
<string
>
Connects user's web3 wallet
Returns
Promise
<string
>
address of the connected account
Defined in
getCurrentWalletAddress
▸ getCurrentWalletAddress(): Promise
<string
>
Returns connected wallet account (Attempts to connect to the wallet if not connected)
Returns
Promise
<string
>
Account address
Defined in
getNetwork
▸ getNetwork(): Promise
<Network
>
Get parameters of the network that the wallet is connected to
Returns
Promise
<Network
>
Network info of where the wallet switched to
Throws
Error if no wallet is installed or if the user rejected adding or switching to the network
Defined in
getSupportedNetworks
▸ getSupportedNetworks(): Object
Get list of networks supported by the configuration
Returns
Object
List and parameters of all configured networks
Defined in
getWeb3Provider
▸ getWeb3Provider(): Promise
<BrowserProvider
>
Returns
Promise
<BrowserProvider
>
Defined in
isCorrectNetworkConnected
▸ isCorrectNetworkConnected(): Promise
<boolean
>
Checks, based on chainId comparison, if the wallet is connected to the default network
Returns
Promise
<boolean
>
true/false if the wallet is connected to the default network
Defined in
isListening
▸ isListening(): boolean
Check if the app is listening to account or network change
Returns
boolean
true if at least one of the listeners is active
Defined in
isSupportedNetworkConnected
▸ isSupportedNetworkConnected(): Promise
<boolean
>
Checks, based on chainId comparison, if the wallet is connected to one of the networks supported by the configuration
Returns
Promise
<boolean
>
true/false
Defined in
isWeb3WalletConnected
▸ isWeb3WalletConnected(): Promise
<boolean
>
Check if a web3 wallet is connected
Returns
Promise
<boolean
>
boolean
Throws
If this is not run in a browser
Defined in
isWeb3WalletInstalled
▸ isWeb3WalletInstalled(): boolean
Check if a web3 wallet is installed
Returns
boolean
boolean
Throws
If this is not run in a browser
Defined in
startListening
▸ startListening(onChangeWalletCallback
): void
Start listening to change in wallet connection and run the callback function if the account changes
Parameters
Name | Type | Description |
---|---|---|
onChangeWalletCallback | (walletAddress : string ) => void | Function to be called if the user changes a connected account |
Returns
void
Defined in
startListeningNetwork
▸ startListeningNetwork(onChangeNetworkCallback
): void
Listen to whether the wallet switches to another network and run the provided callback if yes
Parameters
Name | Type | Description |
---|---|---|
onChangeNetworkCallback | (networkId : bigint ) => void | Function to be called when the wallet switches to another network |
Returns
void
Defined in
stopListening
▸ stopListening(): void
Stop listening to wallet account changes
Returns
void
Defined in
stopListeningNetwork
▸ stopListeningNetwork(): void
Stop listening to network switch
Returns
void
Defined in
switchNetwork
▸ switchNetwork(name
): Promise
<DefaultNetwork
>
Asks user's web3 wallet to switch to a selected network
Parameters
Name | Type | Description |
---|---|---|
name | DefaultNetwork | Name of one of the configured networks ('arbitrum', 'development', or 'arbitrumSepolia' in standard SDK installation) |
Returns
Promise
<DefaultNetwork
>
Name of the network that the wallet was switched to.
Throws
Error if no wallet is present or the user rejected adding or switching to the network