Using connected wallets
The wallets array from the useWallets hook returns a list of all of the wallets a user has connected to your app, including both embedded and external wallets.
Getting an EIP-1193 provider#
All of Openfort's wallets can export a standard EIP-1193 provider object. This allows your app to request signatures and transactions from the wallet, using familiar JSON-RPC requests like personal_sign
or eth_sendTransaction
.
EIP-1193, also known as the Ethereum JavaScript API, is a standardized interface for how applications can request information, signatures, and transactions from a connected wallet.
To get a wallet's EIP-1193 provider, use the openfort getEthereumProvider
method:
When requesting signatures and transactions from the wallet, you can either choose to interface with the EIP-1193 provider directly, or to pass it to a library like wagmi
or viem
.
Getting info about a wallet#
Wallet client type#
Address#
To get the wallet's address, use the object's address field:
_10const address = wallet.address;
Network#
To get the wallet's network, inspect the object's chainId field:
_10const chainId = wallet.chainId;
Wallet client type#
To get the wallet's wallet client type, inspect the object's walletClientType field:
_10const walletClientType = wallet.walletClientType;_10const isEmbeddedWallet = walletClientType === 'Openfort';
The wallet client type refers to the client the user is using to interface with their wallet, such as the MetaMask browser extension, the Rainbow mobile app within your app. Embedded wallets always have a walletClientType
of 'openfort'. External wallets' wallet client types will vary depending on the client the user is using (e.g. 'metamask', 'rainbow', etc.).
You can also request signatures and transactions from the connected wallet via the wallet's EIP-1193 provider.