We consider the provision of an optimal warranty in a continuous-time model with two-sided moral hazard. The optimal warranty must balance the producer's durability incentive and the buyer's maintenance incentive. Too little warranty protection gives the producer too much incentive to produce low durability, while too much warranty protection gives the consumer too much incentive to neglect maintenance. The derived optimal warranty is a "block warranty" that is high for an initial block of time and zero thereafter. The first-best would be available under a very high warranty for a very short time interval, except for the incentive this would create for the consumer to abuse the product to collect the warranty.