Introduction to Clients & Transports
Clients
A Client provides access to a subset of Actions.
A Client in the context of viem is similar to an Ethers.js Provider.
There are three types of Clients in viem:
- A Public Client which provides access to Public Actions, such as
getBlockNumber
andgetBalance
. - A Wallet Client which provides access to Wallet Actions, such as
sendTransaction
andsignMessage
. - A Test Client which provides access to Test Actions, such as
mine
andimpersonate
.
Transports
A Client is instantiated with a Transport, which is the intermediary layer that is responsible for executing outgoing requests (ie. RPC requests).
There are three types of Transports in viem:
- A HTTP Transport that executes requests via a HTTP JSON-RPC API.
- A WebSocket Transport that executes requests via a WebSocket JSON-RPC API.
- A Custom Transport that executes requests via an EIP-1193 Provider (such as
window.ethereum
).