Contracts as legal institutions in organizations of autonomous agents