We model situations in which a principal offers contracts to a group of agents to participate in a project. Agents' benefits from participation depend on the identity of other participating agents. We assume heterogeneous externalities and characterize the optimal contracting scheme. We show that the optimal contracts' payoff relies on a ranking, which arise from a tournament among the agents. The optimal ranking cannot be achieved by a simple measure of popularity. Using the structure of the optimal contracts, we derive results on the principal's revenue extraction and the role of the level of externalities' asymmetry. (JEL D62, D82, D86).