Haney, J.It is alleged in the complaint that the following special act of the territorial legislature was passed and approved January 8, 1873:
“Section 1. That C. J. B. Harris is hereby appointed a commissioner to revise the General Laws of this territory, including the laws passed at the present session, and prepare a compilation of the same, and report said compilation in the form of a bill to the next legislature, also to prepare an index to said compilation.
“Sec. 2. That said commissioner shall have the right to take from the territorial library such laws of this territory as he may need to use in preparing said compilation.
“Sec. 3. That said commissioner is hereby authorized to report such additions to said laws as he may deem necessary to supply uninteiitional omissions, and to make them complete, also to omit such laws or parts of laws as have been rendered superfluous or unnecessary by subsequent legislation.
‘ ‘Sec. 4. This act shall take effect and be in force from and after its passage and approval by the governor.”
It is also alleged that by said act plaintiff was duly appointed and employed as a commissioner to revise the General *455Laws of the territory, and to prepare a compilation of the same, and an index thereto, and to report the said compilation, in the form of a bill, to the next legislature, which would convene in December, 1874; that between January 8, 1873, and December 1, 1874, at Yankton, in said territory, he performed all the conditions on his part to be performed, and did duly and fully perform all the services required by the act; that the territory then received the benefits of such services, which were reasonably worth $5,000, no part of which has been paid by either the territory, the state of North Dakota, or the state of South Dakota, although often demanded, and that such sum, with interest at 7 per cent per annum from December 1, 1874, is now due to plaintiff, and wholly unpaid; that before the commencement of this action plaintiffs claim was presented to the state auditor, who refused to allow the same. Defendant demurs on the ground that the complaint does not state facts sufficient to constitute a cause of action.
If the act created a public office, it is clear plaintiff cannot recover. It made no provision for compensation. The salary attached to a public office belongs to the imcumbent as an incident of his office, not by force of any contract; and where the law makes no provision for the payment of an officer, a promise on the part of the public to pay for his services is not implied from the fact of his election or appointment and the rendition of service. 19 Am. & Eng. Enc. Law, 525. Without attempting to define the distinction between an office and a contract of employment, we will assume that the passage of the act and the performance by plaintiff of the services provided for therein created contractual relations, and proceed to consider the legal obligations resulting therefrom. Nothing is better settled in the law, or has a sounder foundation in good sense, than that a person will not be allowed to demand compensation for services which were rendered gratuitously at the time. Taylor v. Taylor, 1 Lea, 88. The only authority for plaintiff’s employment was the special act, heretofore quoted in *456full. It contains the terms of the contract, if one was made. When a contract is reduced to writing, the intention of the parties is to be obtained from the writing alone, if possible, subject, however, to the other provisions of the title on interpretation of contracts. It may be explained by reference to the circumstances under which it was made, and the matter to which it relates. Comp. Laws, §§ 3554, 3562. It is doubtless true that when a state permits itself to be sued, it consents to go before its courts, and have claims against it determined upon those settled rules of law upon ■ which the responsibilities of ordinary parties litigant are determined. Green v. State, 73 Cal. 29, 11 Pac. 602, and 14 Pac. 610; Metzel v. State, 16 Wis. 370. But in the application of such rules it is necessary, as in the case of municipal corporations, to consider the character of the principal, and the methods and means employed by it in the management of its affairs. Jewell Nursery Co. v. State (S. D.), 67 N. W. 629. The act does not provide for compensation; evidently none was contemplated. This conclusion is not unreasonable. There are numerous considerations which may have prompted plaintiff to perform the services gratuitously. He may have regarded the honor of so responsible a commission, or the information and experience to be derived from the labor, as sufficient compensation. A sale by him of the compilation may have been anticipated. It is hardly possible the legislature would have contracted for this work, intending to pay for it, without fixing the limit of the territory’s liability. It cannot be inferred that its members were so recreant to duty. Plaintiff must have known — he did know — that his compensation, if any was expected by him, must depend upon the voluntary action of a future legislature. None was promised in the law providing for his employment. The inference is, none was intended; and the law does not imply a promise to pay any. Plaintiff was not bound to perform the service without compensation, but, having actually entered upon its performance, he was required to use at least slight care and dili*457gence therein. Comp. Laws, § 3755. By accepting employment under the conditions of the special act, he agreed to do the work for nothing, and cannot claim compensation therefor. Doyle v. Rector, etc., 133 N. Y. 372, 31 N. E. 221.
The other objections suggested by the learned attorney general need not be discussed. The demurrer is sustained with leave to file an amended complaint within thirty days, if plaintiff shall elect so to do.