The paper deals with development of a general theory of the firm. It discusses the demand for such a theory, reviews existing approaches to its generalization, and offers a new variant of general theory of the firm based on the contract theory. The theory is based on minimization of opportunistic behaviour determined by the material structure of production (a classification of ten structural factors is offered). This framework is applied to the analysis of three boundaries problems (boundaries of the job, boundaries of the unit, boundaries of the firm) and five integration dilemmas (vertical, horizontal, functional, related, and conglomerate).