Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
cow-rs
The Rust SDK for the CoW Protocol.
cow-rs is the idiomatic Rust client for trading on CoW Protocol:
build and sign orders, talk to the orderbook, decode on-chain
settlement events. Built on alloy;
ports the canonical types from
cowprotocol/services; locks
every protocol-critical path byte-for-byte against
@cowprotocol/cow-sdk,
cowdao-grants/cow-py and
ethers.
At a glance
- Full order lifecycle: quote, sign, submit, look up, cancel.
- All four signing schemes: EIP-712, EthSign, EIP-1271, pre-sign.
- All eleven chains: Mainnet, BNB, Gnosis, Polygon, Base, Plasma, Arbitrum One, Avalanche, Ink, Linea, Sepolia, plus their barn staging endpoints where the orderbook team publishes them.
- Conformance-locked: 164 tests, with byte-exact goldens
cross-checked against
cowprotocol/services,cowprotocol/contracts, ethers, cow-sdk and cow-py. - Sync core, async client: hashing, signing and contract decoding are pure-compute and need no runtime; the HTTP client is async-tokio and the only piece that depends on one.
- WASM-ready: compiles cleanly to
wasm32-unknown-unknownand has an in-browser end-to-end harness (seetest-harness/) that exercises the live orderbook from the browser; the poll helper is runtime-agnostic so you can drop ingloo_timers::future::sleep.
Install
[]
= "1.0.0-alpha"
The crate is published as cowprotocol on crates.io (the cow-rs name was already taken on
crates.io by an unrelated publisher before this SDK existed); the source lives at
cowdao-grants/cow-rs.
MSRV 1.91, edition 2024.
Quick start: quote, sign, submit
use ;
use ;
use PrivateKeySigner;
# async
See examples/post_order.rs
for the same flow on Sepolia, runnable with a private key in the
environment.
No-async core
Every protocol-critical primitive is synchronous and runtime-free:
OrderData::hash_struct, OrderData::uid, EcdsaSignature::sign,
Signature::recover, DomainSeparator::new, the sol!-generated
contract bindings. You can use cow-rs in a Postgres extension
(pgrx), an FFI shim,
an embedded context, or anywhere else a tokio reactor is hostile,
without pulling in reqwest or tokio.
use ;
use ;
let order = new
.sell_amount
.buy_amount
.valid_to
.kind
.build;
let domain = new;
let owner = address!;
let uid = order.uid;
assert_eq!;
Surface
| Module | What it exposes |
|---|---|
order |
OrderData (12-field signed payload), OrderBuilder, OrderUid, OrderKind, SellTokenSource, BuyTokenDestination, BUY_ETH_ADDRESS, plus the full GET-orders Order, OrderStatus, OrderClass |
order_book |
OrderBookApi with quote / submit / lookup / status / cancel, trades, native price, account orders, app-data PUT / GET, version, total surplus; the runtime-agnostic poll_until helper and the tokio-bound wait_for_order_fulfilled convenience |
signature |
Signature (all four schemes), EcdsaSignature, Recovered, SignatureError |
domain |
DomainSeparator, hashed_eip712_message, hashed_ethsign_message |
chain |
Chain (eleven networks) with orderbook_base_url, orderbook_barn_url, settlement, vault_relayer, subgraph_studio_url |
cancellation |
OrderCancellation (single), OrderCancellations (collection), SignedOrderCancellations |
app_data |
AppDataHash, AppDataDoc (canonical JSON + keccak digest), AppDataCid (IPFS CIDv1 derivation) |
eth_flow |
EthFlowOrder, ETH_FLOW_PRODUCTION, ETH_FLOW_STAGING |
composable |
ConditionalOrderParams, Proof, PollOutcome, ComposableCoW events plus deployment addresses |
contracts |
GPv2Settlement (settle + events), CoWSwapOnchainOrders (ETH-flow events), ERC20, WETH9, GPV2_SETTLEMENT, GPV2_VAULT_RELAYER |
subgraph |
SubgraphClient typed access to CoW's subgraph; totals, daily / hourly volume; opt-in bearer-token auth for the gateway URL |
Everything is re-exported at the crate root: use cowprotocol::....
WASM
cow-rs targets wasm32-unknown-unknown:
- Reqwest's browser fetch backend kicks in automatically on wasm.
OrderBookApi::poll_untilis runtime-agnostic; pair it withgloo_timers::future::sleepinstead oftokio::time::sleep.wait_for_order_fulfilled(the tokio-bound convenience) is non-wasm only.- CI gates
cargo check --target wasm32-unknown-unknownon every push. crates/cow-rs-wasm/ships a#[wasm_bindgen]shim andtest-harness/index.htmldrivesget_quoteandcompute_order_uidagainst the live orderbook from a real browser. Run withjust wasm-harness.
Conformance
cow-rs locks byte-exact equivalence on every protocol-critical path:
- ethers
TypedDataEncoderfor all eleven chains: signed UID, struct hash, domain separator, six order-shape permutations cowprotocol/servicesfor signature recovery and cancellation struct hashescowprotocol/contractsfor the canonicalTYPE_HASHderivation,packOrderUidParamslayout, and event topic hashes- ethers
Wallet.signTypedDatafor the ECDSA(r, s, v)golden - cow-py for the
ConditionalOrderleaf-id derivation - The empty-document app-data digest
keccak256("{}")
Regenerate the cross-implementation vectors with:
&& &&
Status
1.0.0-alpha: the public API is locked unless a critical conformance
issue forces a break. Patch releases (1.0.0-alpha.N) bring additive
features and bug fixes; breaking changes only on minor or major bumps.
Production readiness:
- ✅ Byte-conformance with services / contracts / cow-sdk / cow-py
- ✅ All eleven documented chains
- ✅ All four signing schemes
- ✅ Mock-server integration coverage for every
OrderBookApimethod - ✅ WASM compilation gate in CI plus an in-browser e2e harness
- ✅
cargo clippy -- -Dwarnings, nounsafe, noanyhowin lib code - ⏳ Publishing to crates.io as
cowprotocol
Building
just build # cargo build --all-targets --all-features --workspace
just test # cargo test --all-targets --all-features --workspace
just clippy # cargo clippy ... -- -Dwarnings
just fmt-check
just wasm-check # cargo check --target wasm32-unknown-unknown ...
just wasm-harness # build cow-rs-wasm and serve test-harness/ on :8765
just doc # cargo doc with -D warnings
Layout
crates/cow-rs/ # Library crate; everything re-exported from the root
crates/cow-rs/examples/ # get_quote.rs, post_order.rs
tools/vector-gen/ # Node.js golden-vector generator (ethers reference)
recon/ # Internal recon docs (gitignored, not published)
Contributing
See CONTRIBUTING.md. Briefly: Oxford English in
prose, no em dashes, Conventional Commits, AI-assistance disclosure
in the PR body (never in commits), PRs ≤ 1,500 LoC against develop.
Licence
GPL-3.0-or-later; see LICENSE. Portions adapted from
cowprotocol/services
under MIT / Apache-2.0 with attribution in each affected file.