The paper presents a dynamic game where players contribute to a public bad, invest in technologies, and write incomplete contracts. Despite the n + 1 stocks in the model, the analysis is tractable and the symmetric Markov perfect equilibrium unique. If only the contribution levels are contractible, then investments are suboptimally small if the contract is short term or close to its expiration date. To encourage investments, the optimal contract is more ambitious if it is short term, and it is tougher to satisfy close to its expiration date and for players with small investment costs. If renegotiation is possible, such an incomplete contract implements the first-best. The framework helps to analyse emissions, investments, and international environmental agreements, and the results have important lessons for how to design a climate treaty.