Ethers v5 Adapter
The Ethers v5 Adapter provides integration with ethers.js v5, enabling you to use all CoW Protocol SDK packages with ethers providers and signers.Installation
Constructor
Parameters
Provider | string
required
An ethers v5
Provider instance or an RPC URL string. If a string is provided, a JsonRpcProvider will be created automatically.Signer | string
An ethers v5
Signer instance (e.g., Wallet) or a private key string.Properties
signer
Returns the EthersV5SignerAdapter instance. Throws an error if no signer was provided.utils
Utility methods for working with ethers v5 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). Useful for compatibility with older protocols.IntChainIdTypedDataV4Signer
Signer class for EIP-712 typed data version 4 with integer chain ID handling to fix MetaMask compatibility issues.Methods
getChainId
Returns the chain ID from the connected provider.Promise<number>
getCode
Returns the bytecode at a given address.address(string) - Contract address
Promise<string>
getTransactionReceipt
Returns the transaction receipt for a given transaction hash.transactionHash(string) - Transaction hash
Promise<TransactionReceipt>
getStorageAt
Returns the value from a storage position at a given address.address(string) - Contract addressslot(string) - Storage slot
Promise<BytesLike>
call
Executes a read-only call to a contract.txParams(CallParameters) - Transaction parametersprovider(Provider) - Optional provider override
Promise<string>
readContract
Reads from a contract function using callStatic.address(string) - Contract addressabi(ContractInterface) - Contract ABIfunctionName(string) - Function to callargs(unknown[]) - Function argumentsprovider(Provider) - Optional provider override
Promise<unknown>
getBlock
Returns block information for a given block tag.blockTag(BlockTag) - Block identifierprovider(Provider) - Optional provider override
Promise<Block>
getContract
Creates a contract instance.address(string) - Contract addressabi(ContractInterface) - Contract ABI
GenericContract
setSigner
Sets or updates the signer for the adapter.signer(Signer | string) - New signer or private key
setProvider
Sets or updates the provider for the adapter.provider(Provider | string) - New provider or RPC URL
signerOrNull
Returns the signer adapter or null if not set.EthersV5SignerAdapter | null
createSigner
Creates a new signer adapter from a Signer instance or private key.signerOrPrivateKey(Signer | string) - Signer or private key
EthersV5SignerAdapter