
44 Wn.2d 288 (1954)
266 P.2d 1053
EDWARD HALVER et al., Appellants,
v.
PETER WELLE et al., Respondents.[1]
No. 32555.
The Supreme Court of Washington, En Banc.
February 19, 1954.
Merkel & Cook, for appellants.
E.A. Niemeier, for respondents.
SCHWELLENBACH, J.
This is an appeal from a judgment dismissing an action after the court had sustained a demurrer to plaintiffs' complaint on the ground that the action had not been commenced within the time limited by law.
February 19, 1947, Welle and Billmark, contractors, entered into a written contract with Mr. and Mrs. Halver, to *289 construct a home for them for the agreed price of $8,316, subject to certain conditions and deductions. The home having been completed and certain payments having been made thereon, the contractors, on October 10, 1947, presented the following statement to the Halvers:


    "WELLE & BILLMARK  General Contractors
    P.O. Box 442, Poulsbo, Wash.  Sept. 27  1947
    For Mr. & Mrs. Ed Halver
    Contract Price ....................... $8316.00
    Received to date .....................  7900.00
                                          _________
                                           $1416.00
    Deduct for paint .....................    75.00
                                          _________
                                           $1341.00
    Extras on job
      Glass brick ........................    15.00
      Kitchen window .....................    10.00
      Extras on cupboard .................    75.00
                                          _________
    Balance due .......................... $1441.00
      Less Credit ........................    18.65
                                          _________
                                           $1422.35
    Paid in full Oct. 10, 1947
                                   WELLE & BILLMARK
                                    by Peter Welle"

The payment of $1,422.35 was made October 10, 1947. It is clear from the above statement that there was an error of $1,000 in subtracting $7,900 from $8,316.
This action, seeking the return of the $1,000 overpayment, was commenced January 12, 1953, five years and three months after the payment of October 10, 1947. As stated above, a demurrer to the complaint was sustained and the action dismissed.
The question is whether this action is controlled by the six-year statute of limitations or by the three-year statute of limitations. The six-year statute has reference to:
"An action upon a contract in writing, or liability express or implied arising out of a written agreement." RCW 4.16.040, subd. (2).
*290 The three-year statute of limitations has reference to:
"An action upon a contract or liability express or implied, which is not in writing, and does not arise out of any written instrument; ..." RCW 4.16.080, subd. (3).
In Caldwell v. Hurley, 41 Wash. 296, 83 Pac. 318, Caldwell and Hurley signed a note as cosureties. Caldwell was sued on the note and paid the judgment recovered against him. He then sued Hurley for contribution. The trial court held that the liability existing between Caldwell and Hurley by reason of their having written their names on the back of the note was an implied liability arising out of the written agreement, and upon the payment of the balance due by Caldwell, Hurley became legally bound to contribute half of the sum paid by Caldwell. In affirming the judgment, we said:
"Said subdivision 2 of § 4798, Bal. Code, differs from the statutes of limitation of most, if not all, the other states. In fact, after a painstaking research, we have found no similar statute. The peculiar feature of our statute is that an implied liability arising out of a written instrument is included in the same clause with an express liability arising out of a written contract. The legislature evidently thereby intended that a certain class of actions should be included within the terms of said section which had not in other states been associated or connected with actions on written instruments or actions founded upon written agreements. The liability for contribution of appellant and respondent is an implied liability which arose by reason of their becoming co-sureties on the note. If they had not entered into the written contract which resulted from their signing their names on the back of the note, at the time, under the circumstances, and for the purpose, found by the court, there would be no liability. This liability now exists, is contractual in its nature, and is the direct result of that written agreement by which respondent was compelled to make the payment for which he now seeks contribution."
See, also, Lindblom v. Johnston, 92 Wash. 171, 158 Pac. 972, an action for contribution by a cosurety on a bond, which liability had been paid by one cosurety; also, Pioneer Mining & Ditch Co. v. Davidson, 111 Wash. 262, 190 Pac. *291 242, an action for contribution by one guarantor of the indebtedness of a third person against his coguarantor.
In Oregon-Washington R. & Nav. Co. v. Seattle Grain Co., 106 Wash. 1, 178 Pac. 648, 185 Pac. 583, the railroad company delivered wheat under two bills of lading. No tariff rate was specifically named in the bills of lading; however, it was recited that the property was received subject to the tariffs in effect on the date of shipment. In holding that the six-year statute controlled, we said:
"Since the bill of lading is a contract, it is, of course, a contract in writing, and any action upon the contract, or any action upon a liability, express or implied, arising out of the contract, is within the statute if commenced within six years from the time the cause of action accrued, unless the circumstances that the contract does not specifically name the sum to be charged for the carriage, but provides that the sum to be paid shall be the statutory rate, changes the nature of the liability from one on contract, or one arising out of contract, to a liability created by law. It seems clear to us that it does not have this effect. A liability created by statute is one in which no element of agreement enters. It is an obligation which the law creates in the absence of an agreement. But the present liability is not of this sort. The law but fixes the rate to be charged when a contract of carriage is made. In other words, the law does not create the liability; it but determines the amount of the liability created by the express contract of the parties. As such, it is not a liability created by statute. It is a liability arising out of the contract which the parties have by their writing expressed."
See, also, Warren v. Rickles, 129 Wash. 443, 225 Pac. 422.
In Seattle Lodge No. 211, Loyal Order of Moose v. Goodwin Real Estate Co., Inc., 143 Wash. 210, 255 Pac. 96, the owner of property, contemplating a building, gave a mortgage for $60,000 and, at the same time, entered into an oral agreement by which the mortgagee retained the money and was to make disbursements to the contractor as provided in the construction contract. We held that where the mortgagee failed to pay out the entire sum, the owner's right of action against the mortgagee for the balance due in its hands was an action upon a contract in writing or a liability, *292 express or implied, arising out of a written contract. We said:
"An implied liability here in question, we think, clearly arose out of the written instruments evidencing the loan transaction between appellant and respondent executed on August 3, 1921, less than six years prior to the commencement of this action. The implied liability then so arising from those written instruments, it seems to us, was that appellant would pay over to respondent the full sum of $60,000. The agreement as to the temporary retention of this money by appellant to be paid out on the construction contract did not change the original liability arising out of the written instruments further than to waive the right on the part of respondent to immediately receive the money. That such obligation resting upon appellant was one `arising out of a written instrument', is, we think, rendered plain by the six-year statute."
In Seattle v. Walker, 87 Wash. 609, 152 Pac. 330, the city had paid interest on local improvement district bonds for the period between the date of the bonds and their delivery to the contractor. We had held in State ex rel. Grant Smith & Co. v. Seattle, 74 Wash. 438, 133 Pac. 1005, that payment of interest between such dates was illegal. In the action to recover from Walker the interest which the city had paid illegally, we said:
"In view of our decision in the Grant Smith case, it will not be questioned that this payment was a payment made in violation of law, which may be recovered by the city in a proper action. The city has made an unlawful overpayment. The respondent has received an unmerited enrichment the retention of which is unjust, and in equity and good conscience he should repay the city. The law in such cases implies a liability to refund the illegal payment, and, if not refunded, an action will lie to recover the amount unjustly retained. Keener, Quasi-Contracts, p. 40. The action, therefore, arises out of an implied liability, and the two-year statute may be eliminated. While this payment was incidental to a lawful payment made pursuant to the terms of a written instrument, the payment itself was illegal and was not contemplated by the terms of that instrument. The payment being in violation of the terms of the written contract, it cannot be said to have been made on a written contract or agreement, and not being so made, the implied *293 liability to repay does not arise out of a written instrument, and it follows that the six-year statute cannot apply. This leaves as the controlling statute the three-year limitation, the action being clearly one arising upon an implied liability, not arising out of a written instrument."
Edwards v. Surety Finance Co., 176 Wash. 534, 30 P. (2d) 225, was an action to recover usury paid by the maker of several promissory notes. The question before us was whether the action was controlled by the six-year or the three-year statute of limitations. In holding that the latter statute applied, we said:
"The question immediately before us, upon the first assignment, is this: Is appellant's action based upon an implied liability `arising out of a written agreement,' or, in other words, does a promissory note include, in addition to its express terms, an implication that the payee shall return to the payor the usurious portion of the payment thereon? If this alternative question be answered in the affirmative, then appellant should have been allowed to recover upon his first seven causes of action; if it be answered in the negative, then those causes would, upon their faces, be barred by the three-year statute.
"The notes themselves contained only the promise of the appellant to pay the respective amounts thereof. There was no express promise on the part of respondent to repay any portion of such amounts. Nor can it be said that there was any implied promise on the part of the respondent to repay to appellant any part of the amount received by it. While necessary implication is as much a part of an instrument as an express provision is, the implication must, nevertheless, be such as is within the contemplation of the parties when making the contract, or else necessary to carry their intention into effect. Under such circumstances only will the law imply and enforce the obligation. 6 R.C.L., p. 856, § 244.
"In addition to such contracts as draw their efficacy from the consent of the parties, there is a class of legal obligations which, though of a contractual nature, are not based on contract or consent. These are sometimes spoken of as contracts implied in law, but are usually referred to as quasi, or constructive, contracts. For the purpose of applying the contractual remedy of assumpsit, the law imposes upon such obligation a fictitious promise to pay. The liability upon an obligation of this kind arises purely upon an implication of law, independent of agreement or intention. The law in *294 such cases establishes a duty which may be contrary to the intention of either one, or both, of the parties. 6 R.C.L., p. 588, § 7.
"The right to recover usurious or illegal interest accrues, not from the contract under which usury is paid, nor from any implication contained in the contract itself, but from a duty imposed by law to repay an unjust and unmerited enrichment. The contract under which a usurious rate of interest is reserved having been performed, the law, in turn, implies a contract resting upon the duty to repay the amount unlawfully taken, and furnishes a remedy to the debtor, by an action of assumpsit, to recover such payment."
In the case at bar, there was a clear mistake in arithmetic. If the mistake had been the other way, and the owners had underpaid the contractors $1,000, the latter could have brought action at any time within six years, not because of an implied liability, but because of an express liability upon the written contract to pay the full amount. See Oregon-Washington R. & Nav. Co. v. Seattle Grain Co., supra.
We have here a simple written contract, under the terms of which the builders promised to construct a home for the owners for a certain sum, and the owners promised to pay that sum upon the completion of the work. We are unable to find in the contract any liability or promise on the part of the builders, express or implied, that they would refund any sums overpaid to them. It was not within the contemplation of the parties when the contract was executed. They did not expressly or impliedly stipulate such a liability. To imply such a promise would be to rewrite the contract for the parties.
[1] The written contract was fully executed, and respondents were paid in full. Manifestly, they were overpaid $1,000. They have been unjustly enriched in that amount to the detriment of appellants. In a situation such as this, where no relief has been provided under the contract, the law steps in and provides a remedy. Under the doctrine of quasi-contracts, the law imposes a fictitious promise that one will render to a person entitled thereto that which in *295 equity and good conscience belongs to the latter. Bill v. Gattavara, 34 Wn. (2d) 645, 209 P. (2d) 457.
[2] Where a party receives an overpayment on a written contract, his liability to repay such overpayment does not arise out of the contract under which the overpayment is made, nor from any implied liability contained in the contract itself, but it arises from a duty imposed by law to repay an unjust and unmerited enrichment.
[3] Relief for unjust enrichment is provided for by an action in assumpsit. However, unfortunately for appellants, such an action in this case is barred by the three-year statute of limitations.
The judgment is affirmed.
MALLERY, HILL, DONWORTH, WEAVER, and OLSON, JJ., concur.
HAMLEY, J. (dissenting)
I readily agree that actions to recover money paid by mistake are usually based on the theory of unjust enrichment. I do not agree that this is the only theory on which liability can be predicated under the facts of this case.
The contractors expressly obligated themselves, for a specified sum of money, to supply the materials and construct a house for the owners, according to plan. When they demanded and received one thousand dollars more than the specified sum, they breached these express terms of the contract. This action, therefore, may and should be regarded as one to recover damages sustained by reason of that breach. If so regarded, it is an action upon a contract in writing, or liability express or implied arising out of a written agreement, within the meaning of RCW 4.16.040 (2), Rem. Rev. Stat., § 157 (2).
Of the eight decisions of this court cited in the majority opinion, recovery under the six-year statute of limitations was denied in but two: Seattle v. Walker, 87 Wash. 609, 152 Pac. 330, and Edwards v. Surety Finance Co., 176 Wash. 534, 30 P. (2d) 225. In both of these cases, the excess payments were made in violation of law. The right to recover such payments was, for that reason, held to be predicated upon *296 a liability implied in law. I cannot see that these decisions furnish any basis for a like conclusion here.
We have not previously had occasion to construe RCW 4.16.040 (2) with reference to an overpayment of the kind here presented. It has been noted, however, that this statute is "very broad in its scope." DeBritz v. Sylvia, 21 Wn. (2d) 317, 150 P. (2d) 978. On the basis of the foregoing analysis, I believe that it is broad enough to sustain this action and accomplish simple justice between these parties.
GRADY, C.J., and FINLEY, J., concur with HAMLEY, J.
NOTES
[1]  Reported in 266 P. (2d) 1053.
