What are clients
Clients, in terms of Foton, are logical gates into different parts of the TON blockchain. Instead of exporting many functions from the library, we decided to group the logical parts of blockchain together in the easy-to-use API.
There are four main clients in Foton:
WalletClientUI
– connect to a wallet on TON and send basic transactions with a user interface. To connect, user will choose in a modal window from one of many wallets. Available only in browser environment.WalletClient
– connect to any wallet on TON without user interface. Available in both server and browser environments. Usually, you will callgetWallets
to and then provide a selected wallet toconnect
function.PublicClient
– read data from the blockchain. Relies on TON Center API and does not require a wallet connection.ContractClient
– deploy smart contracts to the blockchain, call their methods, and read their states.
Choosing a client
When deciding on a client for your needs, consider the following:
- When creating backends, use
WalletClient
instead ofWalletClientUI
since it does not require browser environment. - If you want to connect a wallet in a web app quickly, use
WalletClientUI
. It will provide a standard modal window for wallet selection. - If you want a custom wallet selection UI, use
WalletClient
and design your own wallet selection logic. - If you need to get account's balance or read any other data from the blockchain, use
PublicClient
. - If you work with smart contracts, use
ContractClient
.