Interacting with wallets
In the last section we covered how to access a wallet through the SDK, but said nothing about how to interact with it - let’s fix that! You probably noticed the connector
field in the wallet object in the previous section. This is the object that allows you to interact with the wallet. It’s an instance of the WalletConnector
interface, which is a generic interface that allows you to interact with the wallet in a standard way.
There are some fields and methods specific to each chain, so what we’ll do here is list the fields available on every single chain, and then you can go to the specific chain page (i.e. EVM interactions) to see the additional fields and methods available for that chain.
WalletConnector Interface
Field | Description |
---|---|
chainRpcProviders: typeof ChainRpcProviders | undefined | The RPC providers for the chain the wallet is connected to |
walletBookInstance | A list of all of the wallets we support connections with |
didSetup: boolean | Whether the wallet has been set up |
canConnectViaEmail: boolean | Whether the wallet can be connected via email |
canConnectViaCustodialService: boolean | If the wallet needs to be connected via a custodial service such as Blocto, this will be true. |
canConnectViaQrCode: boolean | If the wallet is not installed, and can be connected via a QR code, this will be true. |
canConnectViaSocial: boolean | Whether this connector can be connected via social login. |
connectedChain: Chain | The chain this wallet is connected to |
endSession(): Promise<void> | Close the wallet connection |
fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined> | Get the public address of the wallet |
getAdditionalAddresses(mainAddress?: string): Promise<WalletAdditionalAddress[]> | Get the additional addresses of the wallet, given the main address |
setAdditionalAddresses(mainAddress: string, additionalAddresses: WalletAdditionalAddress[]): Promise<void> | Set the additional addresses of the wallet, given the main address |
getBalance(): Promise<string | undefined> | Get the balance of the wallet |
getConnectedAccounts(): Promise<string[]> | Get the address silently |
getDeepLink(): string | undefined | Get the deep link of the wallet |
getNetwork(): Promise<number | string | undefined> | Get current network of connected wallet |
getNameService(): Promise<NameServiceData | undefined> | Get the name service of the wallet |
getPublicClient(): Promise<unknown> | Get the RPC provider for the wallet |
getSigner(): Promise<unknown> | Get the signer for the wallet |
getSession(): unknown | Promise<T> | Get the session for the wallet |
getWalletClient(): unknown | Get the wallet client |
init(): Promise<void> | Initialize the wallet connector with any async operations |
isEmbeddedWallet: boolean | If the wallet generated by a valid embedded wallet provider |
isInstalledOnBrowser(): boolean | Check if the wallet is installed on the browser |
isWalletConnect: boolean | Flag if it is wallet Connect |
key: string | Override key or the normalized wallet name if needed |
overrideKey: string | undefined | Override key for the wallet (used for injected wallet linking) |
getMobileOrInstalledWallet(): WalletConnector | Whether the wallet connector should fall back to a different wallet connector |
proveOwnership(messageToSign: string): Promise<string | undefined> | In most cases this is an alias for signMessage |
providerResources: string[] | undefined | Additional resources to add to the message to be signed |
setupEventListeners(): void | Set up event listeners for the wallet |
signMessage(messageToSign: string): Promise<string | undefined> | Sign a message |
switchNetworkOnlyFromWallet: boolean | undefined | Requires switching network in the wallet itself |
teardownEventListeners(): void | Tear down event listeners for the wallet |
getSupportedNetworks(): Promise<string[] | undefined> | Get the supported networks (walletConnect wallet only) |
isInitialized: boolean | Whether the connector has been initialized |
setVerifiedCredentials(verifiedCredentials: JwtVerifiedCredential[]): void | Receive the user verified credentials |
ethers?: EthersExtension | An extension to the wallet connector that allows you to interact with the wallet using ethers.js, will only be present if you’ve enabled Ethers |
There’s a lot going on here, so let’s pick out the main aspects you’ll need to work with. We will give examples for EVM here.
Read only actions
If you want to read data from the blockchain, you will want either a “Public Client” (Viem terminology), or a “Provider” (Ethers terminology). Both allow you read only access to the blockchain.
Write actions
If you want to write data to the blockchain, you will need a “Wallet Client” (Viem terminology), or a “Signer” (Ethers terminology). Both allow you to sign transactions with the private key.
What next?
Check out our chain specific docs, illustrating how to take various actions with wallets!
Was this page helpful?