Appearance
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.
Each of these wallets is represented as a ConnectedWallet
object, which you can use to get information about the connection and to request signatures and transactions from the wallet.
Getting info about a wallet
To get information about a connected wallet, first find the corresponding ConnectedWallet
object from the wallets
array.
Address
To get the wallet's address, use the object's address
field:
tsx
const address = wallet.address;
Network
To get the wallet's network, inspect the object's chainId
field:
tsx
const chainId = wallet.chainId;
This is a CAIP-2 chain ID. On EVM networks, it has the format 'eip155:<chain-id>'
.
Wallet client type
To get the wallet's wallet client type, inspect the object's walletClientType
field:
tsx
const walletClientType = wallet.walletClientType;
const isEmbeddedWallet = walletClientType === 'privy';
Privy tip
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, or Privy's UIs within your app. Embedded wallets always have a
walletClientType
of 'privy'
. 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 EIP1193 provider.
Getting an EIP-1193 provider
All of Privy's ConnectedWallet
objects 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
.
INFO
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 ConnectedWallet
object's getEthereumProvider
method:
tsx
const provider = await wallet.getEthereumProvider();
When requesting signatures and transactions from the wallet, you can either choose to interface with the EIP1193 provider directly, or to pass it to a library like wagmi
or viem
.