This paper is concerned with the organization of transactions of goods and services between consecutive stages of activity. A traditional theory of organization, transaction-cost economics, assumes that organizational form (market and hierarchy) is adjusted to the attributes of the transactions. This model is extended here by assuming that the governance of transactions be analyzed within the wider network of the firms they connect and that agents' behavior be guided by adaptive learning rather than by optimization. An agent-based computer simulation model is developed. At each step of time, a matching algorithm using agents' preferances assigns buyers to suppliers or to themselves and implements their choices for market and hierarchy. From step to step, the agents are allowed to adapt their preferences for each other to their experiences.