A statistical physics implementation of Coase׳s theory of the firm