Skip to content

Split viem clients into read and write clients #895

Description

@hugomrdias

There's two very different use cases that we need to consider, Dapps and backend services.

  • Dapps need public nodes and should use the fallback transport
  • Backend services can use authenticated private node and probably also the fallback transport or something like ERPC

We need to split these out and also take into considerations that Dapps use Wagmi and not viem directly.

The issue is how we handle the "clients" in the SDK we should not make reads go through the wallets, we can do that by default and provide a config if the developer wants to configure the "read client" manually.

Considerations

  • We need to rethink how the SDK gets the "client" it can be from viem directly or Wagmi
  • The SDK should have a clear split between a read client and a write (or wallet) client
  • The Core should be specific which type of client it needs for each action
  • In the SDK we can turn a wallet client into a read client with good defaults using fallback transport but also provide a config for manual configuration
  • For Dapps, Detect if the wallet client transport is a custom EIP-1193 transport and default to a fallback transport for the read client using https://docs.filecoin.io/networks-and-tools/networks/mainnet/rpcs
  • For backend service, when the wallet transport is not a custom EIP-1193 we can assume "backend" and keep the same transport for the read client or use default to the public fallback
  • Add a new option to configure manually the read client, this can be just the transport and we use the wallet client to complete the config or just accept a full client from the user.
  • We can optimize by enabling multicall by default on any client in the SDK
  • We should provide good documentation on how to configure client based on docs: add RPC endpoint best practices #873

References:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
🐱 Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions