As the second generation of electronic commerce, the framework of the agent based commerce is proposed. Since the communication messages and solution methods of agents are significantly influenced by the contract type, we have defined the grammar of contracts first. By using this generalized contract grammar, we can express new creative contract types as well as traditional ones like bids and auctions. The messages in agent based commerce have adopted three layers: Agent Communication Language, Electronic Commerce, and Product Specification. For electronic commerce, the agent is regarded as an extension of expert systems with the additional capability of communication control and meta-problem-solving. A prototype of the agent based commerce development environment, UNIK-AGENT, is developed to implement the idea. The procedure of the message generation and solution method selection is illustrated with the case of a computer purchase.