viem and
ethers can use it as a wallet without knowing
about Circle’s bundler or passkey signer.
Use this when your app already has Web3 plumbing in place (a viem or ethers
code path, a wallet connector, or an existing signing pipeline) and you want the
modular wallet to slot in as a drop-in signer. This is a web-only flow.
Before you begin
Before you begin, ensure that you’ve:- Created a modular wallet and have
access to the
smartAccount,bundlerClient, andmodularTransportclient from that tutorial. - Installed
viem. The examples below useviem. Any library that accepts an EIP-1193 provider works the same way.
Steps
Create a read-only public client
Keep the
modularTransport client from the
Create a modular wallet quickstart
for account creation and the bundler. EIP1193Provider also needs a separate
read-only PublicClient on a standard chain RPC (not modularTransport) for
receipt lookups.Web SDK (TypeScript)
Wrap the clients in an EIP-1193 provider
EIP1193Provider is exported from @circle-fin/modular-wallets-core. Construct
it with the bundler client and the read-only public client.Web SDK (TypeScript)
bundlerClient.account is missing.Create a viem wallet client
Pass the provider to
viem through a custom transport.
EIP1193Provider.request returns a full JSON-RPC response, so unwrap result
before returning it to viem.Web SDK (TypeScript)
Sign and read accounts through the provider
Use the wallet client for account discovery and signing. The address passed to
signing methods must match the smart account address.
Web SDK (TypeScript)
signMessage and signTypedData return a hex signature string. Verify it
against the smart account contract using EIP-1271, as shown in
Sign and verify messages.Common methods routed through the provider:eth_accounts,eth_requestAccounts: return the smart account address.personal_sign,eth_signTypedData_v4: sign through the passkey. The address parameter must match the smart account.eth_getTransactionReceipt: reads the receipt through the read-only public client.eth_sendTransaction: wraps the call in a user operation, submits it through the bundler, and returns the resulting transaction hash. It does not enable paymaster sponsorship. For gasless token transfers, send user operations throughbundlerClientas shown in Transfer tokens.