Documentation Index
Fetch the complete documentation index at: https://mintlify.com/cowprotocol/cow-sdk/llms.txt
Use this file to discover all available pages before exploring further.
Viem Adapter
The Viem Adapter provides integration with the viem library, enabling you to use all CoW Protocol SDK packages with viem clients and accounts.Installation
Constructor
Parameters
A viem PublicClient instance created with
createPublicClient.Optional viem account instance or private key string. Can be created with
privateKeyToAccount or obtained from wagmi hooks.Optional WalletClient instance. Use this instead of
signer when working with wagmi’s useWalletClient hook.Properties
signer
Returns the ViemSignerAdapter instance. Throws an error if no signer was provided.utils
Utility methods for working with viem types and contracts.TypedDataVersionedSigner
Signer class for EIP-712 typed data with version support.TypedDataV3Signer
Signer class for EIP-712 typed data version 3 (legacy).IntChainIdTypedDataV4Signer
Signer class for EIP-712 typed data version 4 with integer chain ID handling.Methods
getChainId
Returns the chain ID from the connected provider.Promise<number>
getCode
Returns the bytecode at a given address.address(string): The contract address
Promise<string | undefined>
getTransactionReceipt
Returns the transaction receipt for a given transaction hash.hash(string): The transaction hash
Promise<TransactionReceipt | null>
getStorageAt
Returns the value from a storage position at a given address.address(Address): The contract addressslot(0x${string}): The storage slot
Promise<0x${string}>
call
Executes a read-only call to a contract.txParams(TransactionParams): Transaction parametersprovider(PublicClient, optional): Override provider
Promise<string>
readContract
Reads from a contract function.address(string): Contract addressabi(Abi): Contract ABIfunctionName(string): Function name to callargs(ContractValue[], optional): Function argumentsprovider(PublicClient, optional): Override provider
Promise<unknown>
getBlock
Returns block information for a given block tag.blockTag(BlockTag): Block tag (e.g., ‘latest’, ‘pending’, block number)provider(PublicClient, optional): Override provider
Promise<Block>
getContract
Creates a contract instance with a compatible interface.address(string): Contract addressabi(Abi): Contract ABI
GenericContract
setSigner
Sets or updates the signer for the adapter.signer(Account | PrivateKey): New signer to use
setProvider
Sets or updates the provider for the adapter.provider(PublicClient): New provider to use
PublicClient
signerOrNull
Returns the signer adapter or null if not set.ViemSignerAdapter | null
createSigner
Creates a new signer adapter from an account or private key.signer(Account | PrivateKey | ViemSignerAdapter): Signer to wrap
ViemSignerAdapter