We formalize the link between optimal cost-sharing contracts and the production technology in the presence of moral hazard by appealing to several well-known results from duality theory. Building on intuitions from the interlinkage literature, we show that optimal contractual structure is determined by the (i) substitution possibilities that exist between different observable factor inputs, as well as (ii) between these inputs and unobservable effort. We endogenize contractual choice using landlord characteristics as instruments, exploiting the fact that, in our dataset, landlords interact with several tenants and vice versa. The approach is applied to an unbalanced plot-level panel of cost-sharing contracts in a Tunisian village, using a translog representation of the restricted profit function. Contractual terms are found to be a significant determinant of input use and therefore lead to Marshallian inefficiency, while the optimality of the underlying contractual structure is rejected.