The facts, as alleged in the complaint, may be deemed sufficient to establish a lien in behalf of Phelps upon the fund represented by the judgment against Punk, for the value of his services as attorney and counsel for the defendant’s assignor in the action brought to restrain its collection, and in that view it may be assumed that the submission for arbitrament of the question of the value of such services was had.
The assignment by Phelps to the plaintiff, as alleged in the complaint, was of a claim against Alexander for services, together with his lien upon the fund as security for its payment, and did not pur*187port to transfer any claim due the assignor from the defendant. But the judgment and the securities for its payment having been assigned by Alexander to the defendant, the latter had some interest in the matter of the amount of the lien upon the fund. And the plaintiff, from the assignment to him, derived the right to charge it fey action in equity, to which the defendant would have been a necessary party. But at the time of the assignment to the plaintiff, Phelps had no claim or right of action at law against the defendant which was transferred by it. And the defendant had no right to set-off or assert, by way of counter-claim as against the plaintiff as assignee, the debt it then had against Phelps. The right to do so is dependent upon the statute, which provides that “ if the action is founded upon a contract which has been assigned by the party thereto, * * * a demand existing against the party thereto * * * at the time of the assignment thereof, and belonging to the defendant, * * * must be allowed as a counter-claim * * * if it might have been so allowed against the party * * * while the contract belonged to him.” (Code Civ. Pro., § 502, sub. 1.)
The contract before and at the time of the assignment was between Phelps and Alexander, and no right of set-off then existed with the defendant against the plaintiff’s assignor affecting the claim assigned, and, therefore, the claim derived from the assignment by the plaintiff was in no manner taken subject to any right of the defendant to make the set-off. And in this respect the provision of the Code is substantially the same as the prior statute. (2 R. S., 354, § 18, sub. 8; Myers v. Davis, 22 N. Y., 489; Martin v. Kunzmuller, 37 id., 396; Taylor v. Mayor, etc., 82 id., 10.) This action and the right to maintain it depend upon a contract of the defendant, express or implied, made since the assignment to the plaintiff, and accruing to him as such assignee. But it is contended on the part of the defendant that the complaint does not state a cause of action against the defendant. If that is so, the plaintiff’s demurrer to the answer was properly overruled, without reference to the question of the sufficiency of the alleged counter-claim. (People v. Booth, 32 N. Y., 397.)
The complaint alleges the assignment of the judgment to the defendant; the lien of Phelps upon the fund represented by it, on *188account of bis claim for services as attorney and counsel against tbe defendant’s assignor; tbe assignment of tbat claim to tbe plaintiff; tbe agreement between bim and tbe defendant to submit tbe matter of tbe claim to arbitration to ascertain its amount in wbicb it was agreed tbat tbe amount awarded should be paid to tbe plaintiff out of tbe judgment and funds so assigned to tbe defendant; tbe making the award and its amount, and tbe subsequent receipt by tbe defendant of tbe amount of tbe judgment, etc. These facts are sufficient to furnish a claim and cause of action in favor of tbe plaintiff against tbe defendant. And for tbat purpose it is not necessary now to determine whether or not tbe allegation is sufficient to constitute an express agreement of tbe defendant to pay the amount to tbe plaintiff. Tbe alleged agreement of tbe defendant, tbat it should be paid out of the particular fund to tbe plaintiff in view of tbe purpose of tbe arbitration and award, was a recognition by tbe latter tbat tbe plaintiff had tbe right to the amount of tbe award established by it from tbe proceeds of tbe judgment. And tbe fact that tbe defendant afterward received tbe fund was sufficient to permit recovery of tbe amount, as for money bad and received by tbe defendants to and for tbe use of tbe plaintiff. In tbe view taken of the question here, tbe result must be tbe same whether the'right of action rests upon that ground or upon an express agreement of tbe defendant to pay tbe plaintiff from tbe proceeds of tbe judgment the amount of the award.
Tbat part of the answer alleging tbe matter of counter-claim is not sufficient to support tbe defendant’s claim against tbe plaintiff as assignee, unless the allegations of tbe answer place tbe plaintiff’s assignor in such beneficial relation to the subject of the action as to justify it. The answer in question alleges “ tbat at the time of tbe alleged assignment to tbe plaintiff, set forth in tbe complaint of tbe cause of action therein set forth, Phelps was indebted to tbe defendant,” etc. This is adopted as tbe basis upon which tbe right to charge tbe countei-claim against tbe cause of action and assignment as alleged in tbe complaint is asserted. Then tbe answer proceeds to allege that tbe assignment to the plaintiff was “ merely nominal, without consideration, and made and accepted for the benefit of said Phelps, and with tbe fraudulent purpose of enabling said Phelps (under *189cover thereof) to take hold, use and appropriate the proceeds of such award free and exempt from the claims and demands of the creditors of said Phelps and particularly this defendant.” The question arises whether this allegation brings the case within the statute, which provides, “ if the plaintiff is a trustee for another, or if the action is in the name of a plaintiff who has no actual interest in the contract upon which it is founded, a demand against the plaintiff shall not be allowed as a counter-claim, but so much of a ■demand existing against the person whom he represents, or for whose benefit the action is brought as will satisfy the plaintiff’s demand, must be allowed as a counter-claim, if it might have been so allowed in an action brought by the person beneficially interested.” (Code Civil Pro., § 502, sub. 3.)
This right of defense, founded in set-off or counter-claim as it is now defined as against an assignee, is wholly statutory. (Wheeler v. Raymond, 5 Cow., 231.) And the allegation in support of it must in express terms bring such defense within the statute. .We think that is not done in this case. It is neither alleged that the plaintiff was trustee for Phelps, or that the plaintiff had no interest in the subject of the action within the meaning of the statute. In matters of pleading nothing will be inferred, but all elements requisite to the cause of action or defense must be alleged.
The purpose of the assignment to the plaintiff, as distinguished from its legal effect, is not important for the purposes of this question in this action at law. Whether, within the meaning of this statute, the plaintiff was a trustee or had no interest in the subject-matter, of the action, depended upon the legal effect of the assignment to him as between the parties to it.
The intent of the parties is not the ■ subject of inquiry. The plaintiff may have the legal right as against his assignor to the entire subject of the cause of action, and yet the assignment be held fraudulent as to the creditors of the latter in a proper action for the purpose, by reason of some understanding that the assignor shall have some of the benefit to be derived,from it, the trust in such case is not created by the instrument, but is adjudged by the court as the result of fraud for the purposes of the remedy in behalf of creditors, that question cannot be raised in this action for the purpose of the alleged counter-claim.
*190The allegations in the answer do not necessarily go to the terms or legal effect of the assignment, but may relate only to the purpose and intent of the-parties in making and taking it. For aught that appears by the allegations of the answer the assignor has no legal interest or right which he can assert against the plaintiff to any part of the subject of the action.
It is unnecessary to consider the question which might have been presented, if it had appeared by the pleadings, or been alleged by the answer, that the money was received by the defendant upon the judgment prior to the assignment by Phelps to the plaintiff. If these views are correct, the defendant has faffed to allege facts sufficient to constitute a counter-claim or set-off, and the demurrer was well taken.
The recovery of costs of the demurrer and of this appeal by the plaintiff must await and depend upon the defeat of the defendant upon ,the issues of fact. If the latter prevails, then the plaintiff will not be entitled to recover such costs. (Masters v. Barnard, 6 How., 113; Belknap v. McIntyre, 2 Abb., 366; Mora v. Sun Mut. Ins. Co., 13 id., 304-308 ; S. C., 22 How., 60.)
The judgment should be reversed, with leave to the defendant to amend answer within twenty days on payment of costs.
Smith, P. J., Baeeee and Haight, JJ., concurred.Interlocutory judgment reversed and demurrer sustained, with leave to the defendant to amend answer within twenty days on payment of the costs of the demurrer and of this appeal, and in case the defendant does not elect to amend, that the plaintiff recover such costs in case he succeeds in the action.