Ethers v5 Adapter
The Ethers v5 Adapter provides integration with the ethers.js v5 library, enabling you to use all CoW Protocol SDK packages with ethers v5 providers and signers.Installation
Constructor
Parameters
Provider | string
required
An ethers v5 Provider instance (e.g.,
JsonRpcProvider) or an RPC URL string. If a string is provided, a JsonRpcProvider will be created automatically.Signer | PrivateKey
Optional ethers v5 Signer instance (e.g.,
Wallet) or private key string. If a private key is provided, a Wallet will be created automatically.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): The contract address
Promise<string>
getTransactionReceipt
Returns the transaction receipt for a given transaction hash.transactionHash(string): The transaction hash
Promise<TransactionReceipt>
getStorageAt
Returns the value from a storage position at a given address.address(string): The contract addressslot(BigNumberish): The storage slot
Promise<BytesLike>
call
Executes a read-only call to a contract.txParams(TransactionParams): Transaction parametersprovider(Provider, optional): Override provider
Promise<string>
readContract
Reads from a contract function using callStatic.address(string): Contract addressabi(Abi): Contract ABIfunctionName(string): Function name to callargs(ContractValue[], optional): Function argumentsprovider(Provider, optional): Override provider
Promise<unknown>
getBlock
Returns block information for a given block tag.blockTag(string): Block tag (e.g., ‘latest’, ‘pending’, block number)provider(Provider, optional): Override provider
Promise<Block>
getContract
Creates a contract instance.address(string): Contract addressabi(Abi): Contract ABI
GenericContract
setSigner
Sets or updates the signer for the adapter.signer(Signer | PrivateKey): New signer to use
setProvider
Sets or updates the provider for the adapter.provider(Provider): New provider to use
Provider
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 | PrivateKey | EthersV5SignerAdapter): Signer to wrap
EthersV5SignerAdapter