Skip to main content

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

Throws

Unsupported network error if the user is on incorrect network, and neither global settings nor the parameter requires the switch

Parameters

NameTypeDefault valueDescription
callbacks?IGenericTransactionCallbacksundefined-
forcebooleanfalseTrue to force switching to the default network

Returns

Promise<void>

Defined in

wallet/index.ts:163


checkIsWalletInstalled

checkIsWalletInstalled(): any

Check if a web3 wallet is installed

Throws

If this is not run in a browser

Returns

any

installed web3 provider or null if none

Defined in

wallet/index.ts:306


connect

connect(): Promise<string>

Connects user's web3 wallet

Returns

Promise<string>

address of the connected account

Defined in

wallet/index.ts:71


getNetwork

getNetwork(): Promise<Network>

Get parameters of the network that the wallet is connected to

Returns

Promise<Network>

Network parameters

Defined in

wallet/index.ts:184


getSupportedNetworks

getSupportedNetworks(): Object

Get list of networks supported by the configuration

Returns

Object

List and parameters of all configured networks

Defined in

wallet/index.ts:211


getWalletAccount

getWalletAccount(): Promise<string>

Returns connected wallet account (Attempts to connect to the wallet if not connected)

Returns

Promise<string>

Account address

Defined in

wallet/index.ts:327


getWeb3Provider

getWeb3Provider(): Promise<Web3Provider>

Returns

Promise<Web3Provider>

Defined in

wallet/index.ts:288


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

wallet/index.ts:220


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

wallet/index.ts:270


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

wallet/index.ts:230


startListening

startListening(onChangeWalletCallback): void

Start listening to change in wallet connection and run the callback function if the account changes

Parameters

NameTypeDescription
onChangeWalletCallback(walletAddress: string) => voidFunction to be called if the user changes a connected account

Returns

void

Defined in

wallet/index.ts:244


startListeningNetwork

startListeningNetwork(onChangeNetworkCallback): void

Listen to whether the wallet switches to another network and run the provided callback if yes

Parameters

NameTypeDescription
onChangeNetworkCallback(networkId: number) => voidFunction to be called when the wallet switches to another network

Returns

void

Defined in

wallet/index.ts:258


stopListening

stopListening(): void

Stop listening to wallet account changes

Returns

void

Defined in

wallet/index.ts:277


stopListeningNetwork

stopListeningNetwork(): void

Stop listening to network switch

Returns

void

Defined in

wallet/index.ts:284


switchNetwork

switchNetwork(name): Promise<DefaultNetwork>

Asks user's web3 wallet to switch to a selected network

Throws

Error if the user rejected adding or switching to the network

Parameters

NameTypeDescription
nameDefaultNetworkName of one of the configured networks ('arbitrum', 'development', or 'goerli' in standard SDK installation)

Returns

Promise<DefaultNetwork>

Name of the network that the wallet was switched to. Null if no wallet is installed

Defined in

wallet/index.ts:100