Ethers v6 Adapter
The Ethers v6 Adapter provides integration with the ethers.js v6 library, enabling you to use all CoW Protocol SDK packages with ethers v6 providers and signers.Installation
Constructor
Parameters
An ethers v6 Provider instance (e.g.,
JsonRpcProvider) or an RPC URL string. If a string is provided, a JsonRpcProvider will be created automatically.Optional ethers v6 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 EthersV6SignerAdapter instance. Throws an error if no signer was provided.utils
Utility methods for working with ethers v6 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 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 | null>
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 static call.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 with a compatible interface.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.EthersV6SignerAdapter | null
createSigner
Creates a new signer adapter from a Signer instance or private key.signerOrPrivateKey(Signer | PrivateKey | EthersV6SignerAdapter): Signer to wrap
EthersV6SignerAdapter