Pryor, J.
The precise point presented by the appeal was determined by us in Cornell v. Donovan, 14 Daly, 295; and we are concluded by that decision unless, upon consideration, we find the contrary adjudication by the general term of the supreme court, first department, in Furber v. McCarthy, 7 N. Y. Supp. 613, to be supported by the sounder reason. We do not so find, but, on the contrary, we are of opinion that our own ruling is sustained by the obvious intént of the Code, as well as by the principles and analogies of the law. The single question in controversy is whether an action on an undertaking to obtain an attachment be an action on contract, within the purview of subdivision 2, § 501, Code Civil Proc. The provisions of the Code allowing counter-claims, like the similar provisions of the English law, are designed to lessen the burdens and to facilitate the operation of remedial justice, and accordingly should receive a liberal construction in aid of their beneficent policy. Obviously, their aim would be defeated if the language of the statute be taken tó mean only a “contract,” in the strict and technical sense of the term. Three classes of obligations are known in law as “contracts,” and are especially so distinguished for the purposes of remedial, justice, namely, “express contracts,” “implied contracts,” and “constructive contracts.” “Express contracts” are those the terms of which are averred and uttered by the parties. Broom, Com. Law, 250. “Implied contracts” are such as reason and justice dictate, and which the law, therefore,- presumes that every man *519undertakes to perform. 2 Bl. Comm. 443. “Constructive contracts” arise “ when the law prescribes the rights and liabilities of persons who have not in reality entered into any contract at all, but between whom circumstances make it just that one should have a right, and the other be subject to a liability, similar to the rights and liabilities in cases of express contract.” Dan-forth, J., in People v. Speir, 77 N. Y. 144, 150; 1 Add. Cont. 55. Whether the latter two classes will be construed as contracts depends upon the nature of the particular case; as, for example, whether it be sought to enforce a penalty or to enlarge a remedy. Hence while in McCaun v. Railroad Co., 50 N. Y. 176, the court held that an action to recover a statutory penalty was not an action upon a contract, within the meaning of section 129 of the former Code, on the other hand the same court hold that, where an agent converts property of his principal, the latter has his election to sue as for breach of contract or for the conversion; and, if he elects to proceed for a breach of contract, he may interpose it as a counter-claim in an action upon contract brought against him by his agent. Coit v. Stewart, 50 N. Y. 17; Andrews v. Bank, 26 N. Y. 298. The sole authority adduced by the supreme court to sustain its contention is McCaun v. Railroad Co., supra; but liability for a statutory penalty wants that essential element of contract here apparent, namely, the express agreement of the defendants. ITor, with all respect for the ability of the supreme court, general term, do we perceive in its argument any more substantial support of its decision. It is said that “the undertaking is not a contract, because it is unilateral;” but, in the learning of the profession, “unilateral” engagements are a familiar class of contracts. “Executory contracts are of two kinds, ‘bilateral’ and ‘unilateral.’ When the consideration on each side is a promise, the contract is bilateral; a binding promise, the consideration of which is anything else than a promise, is a unilateral contract.” Langd. Cas. Cont. 1092-1094. Then it is objected that “the party for whose benefit the undertaking was given had no volition in the matter;” to which the all-sufficient answer is that the sureties on the undertaking had an option whether to execute it or not, and that the party for whose benefit it was given emphatically accepts it by seeking to enforce it. Again, it is argued that the undertaking has no consideration to support it, and that its only obligation arises from the statute. But a manifest consideration of benefit moving to the plaintiffs in the attachment suit was the security for his claim acquired by the attachment, and that the obligation of the undertaking may subsist independently of statute is settled by repeated adjudications. Association v. Read, 124 N. Y. 189, 26 N. E. Rep. 347; Carr v. Sterling, 114 N. Y. 558, 22 N. E. Rep. 37; Toles v. Adee, 84 N. Y. 222. Still further, it is urged that a defendant in an undertaking on attachment “is not a party to it, and no way consents to it.” But one for whose benefit a contract is made, though not a party to it, may sue upon it, (Lawrence v. Fox, 20 N. Y. 268;) and, as already stated, he consents to it by seeking to enforce it.
Finally, it is intimated by the learned supreme court that an undertaking on attachment is not a contract because it is imposed upon the obligor by statute, and consent is an essential element of contractual liability. We have already adverted to the fact that the sureties are not compelled to give the undertaking; and neither, for that matter, is the plaintiff in the attachment suit, for he has an election to give the undertaking or forego the attachment. Consent, undoubtedly, is a necessary element of a contractual obligation; but the consent need not be actual, but may be implied by law against even the express volition of the party. Hence a judgment in invitum is a contract, and, though obtained for a tort, may be interposed as a counter-claim in an action on contract. Taylor v. Root, *43 N. Y. 335; Badlam v. Springsteen, 41 Hun, 160; Clark v. Story, 29 Barb. 295; Wells v. Henshaw, 3 Bosw. 625. tio, “if one man has obtained money from another, through the medium of *520oppression, imposition, extortion, or deceit, or by the commission of a trespass, such money may be recovered back; for the law implies a promise by the wrong-doer to restore it to the rightful owner, although it is obvious that this is the very opposite of his intentions. People v. Speir, 77 N. Y. 150. And such constructive contract is available as a counter-claim in an action on contract. Coit v. Stewart, 50 N. Y. 17. So a statutory penalty is recoverable by action of debt. 2 Greenl. Ev. § 279. Indeed, any pecuniary liability imposed by statute is enforceable by action ex eontraetu, upon the legal implication that a man agrees to pay that which the law makes it his duty to pay. 5 Amer. & Eng. Enc. Law, 166-173. Excepting the case in the supreme court which we have ventured to criticise, the courts uniformly treat statutory undertakings as imposing contract obligations, (In re Grove, 20 Abb. N. C. 164;) and hence “bail are sureties, with the rights and remedies of sureties in other cases,” (Toles v. Adee, 84 N. Y. 239.) We adhere to our decision in Cornell v. Donovan, and accordingly the order is reversed, with costs. All concur.