Client Factories
Three factories that create bundler-backed clients with the appropriate ZKP action extensions. Gas is sponsored via ERC-4337 paymaster by default.
All three factories share a common chain-target shape: chain: Chain plus optional transport: Transport (defaults to http()). For sharing one underlying chain reader across multiple factory clients, pass a pre-built client: PublicClient instead of chain — the factory uses it directly.
createEvmClient
EVM-side actions via bundler — bound to an EOA permit signer. For public-to-encrypted deposit, auto-encrypt toggle, and EIP-3009 recipient-bound ERC-20 transfers.
import { createEvmClient } from '@cardinal-cryptography/sdk'
const client = await createEvmClient({
chain: Chain,
transport?: Transport, // defaults to http()
// OR: client: PublicClient // override; replaces chain + transport
account: LocalAccount,
sharedAccountAddress?: Address,
bundlerUrl?: string,
paymaster?: EbPaymasterConfig,
tokens?: TokenMap,
})
account is the user's EOA. createEvmClient uses the SharedAccount as the UserOp sender, so the contract sees msg.sender = SharedAccount — public-to-encrypted deposits go through the publicToEncryptedTransferWithAuth permit variant, signed by account. Tokens are burned from account.address.
Methods available: Public reads + EVM writes (transfer to encrypted address, set auto-encrypt, EIP-3009 transferWithAuthorization).
createDecryptClient
Read-only. No bundler, no transactions.
import { createDecryptClient } from '@cardinal-cryptography/sdk'
const client = createDecryptClient({
chain: Chain,
transport?: Transport, // defaults to http()
// OR: client: PublicClient
zkpAccount: ZkpReadAccount,
tokens?: TokenMap,
})
Methods available: Public reads + decrypt balance and history.
createFullClient
ZK-side actions via bundler — encrypted transfers and proof-backed register.
import { createFullClient } from '@cardinal-cryptography/sdk'
const client = await createFullClient({
chain: Chain,
transport?: Transport, // defaults to http()
// OR: client: PublicClient
zkpAccount: ZkpAccount,
sharedAccountAddress?: Address,
bundlerUrl?: string,
paymaster?: EbPaymasterConfig,
tokens?: TokenMap,
})
zkpAccount is the ZK identity (controller-auth signer + prover-bound).
Methods available: Public reads; decrypt balance and logs; ZK writes (sendRegisterEpk, sendEncryptedTransfer, sendEncryptedToPublicTransfer, plus their prepare* variants).
Bundler config parameters
| Parameter | Type | Description |
|---|---|---|
client | PublicClient | Optional alternative to chain + transport — viem public client for chain reads. |
account | LocalAccount | User's EOA. Required for createEvmClient only — signs EIP-712 permits for the EVM action surface (zkpEvmActions). createFullClient does not take an EOA; it uses zkpAccount for controller auth. |
sharedAccountAddress | Address | Deployed SharedAccount contract |
bundlerUrl | string | ERC-4337 bundler JSON-RPC endpoint |
paymaster.paymasterUrl | string | Paymaster backend URL |
paymaster.signPartnerContext | Function | Authenticates your app with the paymaster |
tokens | TokenMap | Optional custom token name-to-address mapping |
zkpAccount | ZkpAccount | Required for createFullClient only |
Capability matrix
| Method | Evm | Decrypt | Full |
|---|---|---|---|
getEncryptedBalanceCiphertext | Yes | Yes | Yes |
getAutoEncryptZkpAddress | Yes | Yes | Yes |
getQuorumPublicKey | Yes | Yes | Yes |
getPermitNonce | Yes | Yes | Yes |
getAutoEncrypt | Yes | Yes | Yes |
getEncryptedBalanceLogs | Yes | Yes | Yes |
getTokenName | Yes | Yes | Yes |
sendPublicToEncryptedTransfer | Yes | -- | -- |
preparePublicToEncryptedTransferWithAuth | Yes | -- | -- |
sendSetAutoEncrypt | Yes | -- | -- |
signAuthorization | Yes | -- | -- |
toSignedTransaction | Yes | -- | -- |
prepareTransferWithAuthorization | Yes | -- | -- |
sendTransferWithAuthorization | Yes | -- | -- |
getAuthorizationState | Yes | -- | -- |
getDecryptedBalance | -- | Yes | Yes |
getDecryptedBalanceLogs | -- | Yes | Yes |
sendRegisterEpk | -- | -- | Yes |
prepareEncryptedTransfer | -- | -- | Yes |
sendEncryptedTransfer | -- | -- | Yes |
prepareEncryptedToPublicTransfer | -- | -- | Yes |
sendEncryptedToPublicTransfer | -- | -- | Yes |
signTransaction (controller) | -- | -- | Yes |
sendPreparedTransaction | -- | -- | Yes |