We introduce a model in which firms trade goods via bilateral contracts which specify a buyer, a seller, and the terms of the exchange. This setting subsumes (many-to-many) matching with contracts, as well as supply chain matching. When firms relationships do not exhibit a supply chain structure, stable allocations need not exist. By contrast, in the presence of supply chain structure, a natural substitutability condition characterizes the maximal domain of firm preferences for which stable allocations always exist. Furthermore, the classical lattice structure, rural hospitals theorem, and one-sided strategy-proofness results all generalize to this setting.