
175 Cal.App.2d 354 (1959)
STEVE SCHNEIDER, Appellant,
v.
WILLIAM Z. ZOELLER et al., Defendants; PACIFIC INDEMNITY COMPANY (a Corporation), Respondent.
Civ. No. 24098. 
California Court of Appeals. Second Dist., Div. One.  
Nov. 17, 1959.
 Clifton A. Hix and Elizabeth Hix for Appellant.
 Mewborn & Hitchcock and Donald J. Hitchcock for Respondent.
 LILLIE, J.
 William A. Zoeller, a defendant in the within action and prior to its institution, sued appellant herein for the recovery of $8,500 on March 12, 1951, at which time a writ of attachment was issued; the Pacific Indemnity Company, respondent herein, executed and filed an undertaking in the amount of $2,500 and appellant's hammer then in storage *357 with the Belyea Trucking Company was attached by the sheriff. Appellant did not learn of the attachment until 10 months later when, on or about December 15, 1951, he sold the hammer to C.B.S. Steel and Forge Company for $15,000 and Belyea refused to deliver it to the buyer because of the attachment lien. Appellant immediately communicated with his counsel, Clifton A. Hix, who entered into negotiations with Zoeller's attorney, Donald Armstrong, culminating in an oral agreement between them whereby the latter would release the attachment upon delivery to him of a cashier's check in the sum of $8,500 in lieu of the hammer then in custody of the sheriff. Pursuant thereto, the check payable to both counsel was delivered to Mr. Armstrong on January 10, 1952, whereupon he executed a release of attachment and the sheriff released the hammer. No other property owned by appellant was thereafter levied upon by the sheriff under the writ. Accompanying the check was a letter signed by both counsel setting up the oral agreement reciting that the check be held by Mr. Armstrong until final determination of the cause. Accordingly, the check was held by him from January 10, 1952, to June 20, 1956, when he delivered it to Mr. Hix after appellant prevailed in the action. The record does not disclose any discharge of the writ of attachment prior to that time.
 Thereafter, in the within action appellant sued Zoeller and the Pacific Indemnity Company for damages on attachment. The trial court entered judgment against the latter in favor of appellant in the sum of $700 ($500 loss of credit and $200 attorneys' fees); appellant took nothing against defendant Zoeller. This appeal is directed solely against Pacific Indemnity Company.
 The only issue raised by appellant is that of the sufficiency of the damages. He does not question the $500 loss of credit, but claims that no sum was allowed as interest on the $8,500 withheld from him from January 10, 1952, to June 20, 1956; and that the amount allowed for attorney's fees in the sum of $200 was inadequate. He argues that the levy under the writ of attachment, wrongful in the first instance, imposed a lien on his personal property the release of which he could secure only by depositing the $8,500, which he did; and that this amount was withheld from him during the period from January 10, 1952, to June 20, 1956, upon which he is entitled to interest for loss of its use.
 Respondent defends the judgment on the ground that as *358 surety it is not liable for interest on the money because it constitutes damage arising after the release of the attachment and as the result not of the attachment but of a private agreement between counsel to which it was not a party.
 [1] It is well settled that the liability of a surety on its attachment undertaking arises only by virtue of its contract (Elder v. Kutner, 97 Cal. 490 [32 P. 563]) and the statutory provisions under which it is executed and given (Code Civ. Proc.,  539), and is measured by the terms and conditions of the bond and the limitations provided under the section. Section 539, under which the bond was given by respondent, requires a written undertaking to the effect that if defendant recovers judgment plaintiff will pay all costs that may be awarded to defendant and "all damages which may he sustain by reason of the attachment not exceeding the sum specified in the undertaking." The bond issued by it employs the same language and provides, among other things, that if defendant recovers judgment plaintiff shall pay, besides costs, "all damages which he may sustain by reason of said attachment not to exceed $2,500."
 [2] We are aware of no provision in the law or in respondent's undertaking that limits its liability only to that damage arising during the period appellant's hammer was under attachment as argued by respondent; on the contrary, by statute and the express terms of its bond, respondent's liability extends to damage sustained "by reason of the attachment." And because of this it does not appear material that respondent may not have been a party to the agreement between counsel under which the $8,500 was deposited and the hammer was released from the attachment, or that the writ may or may not in fact have been discharged. The real issue is whether damage in the form of interest for loss of use of the $8,500 withheld from appellant was sustained by reason of the attachment and a proximate result thereof.
 [3] The purpose of a writ of attachment is to effect a lien on the property of the defendant as security for the payment of any judgment plaintiff may recover against him. [4] The procedure for its issuance and levy, and the attachment of property, contemplates an exercise of physical custody over the personal property attached by the sheriff under the writ (Code Civ. Proc.,  540, 542, 542b). [5] Release of property from the operation of the writ may be effected by several methods--by the filing of an undertaking or the deposit of money by defendant prior to judgment under section 540, or *359 by a discharge of the writ itself (Code Civ. Proc.,  553, 554, 555, 556- 558). [6] Release of property levied upon under the writ may be had before judgment if defendant gives plaintiff security by way of an undertaking or deposits a sum of money with the sheriff, constable, or marshal in an amount sufficient to satisfy the demand against him, which shall be taken "in lieu of the property which has been or is about to be attached" ( 540). [7] The purpose of the section is to provide a method of releasing to the defendant for his use property already levied upon, or protecting against a lien property about to be attached under a writ. Although provision thereunder is made not only for release of property under a writ of attachment already levied but for a substitution of an undertaking or bond for property about to be attached under a writ prior to judgment, none is made for discharge of the writ upon the release or substitution. Provision for discharge is found only in section 553 (after judgment in favor of defendant), section 554 (after defendant has appeared in the action upon his application to the court upon giving an undertaking) and sections 556-558 (upon motion of the defendant when attachment has been improperly issued).
 It is conceded that the original action and undertaking were filed and the attachment levied on March 12, 1951, at which time the hammer was attached; that on January 10, 1952, a cashier's check in the sum of $8,500 was delivered to Zoeller's attorney, Mr. Armstrong, "with the understanding that the attachment on the hammer would be released"; that after delivery thereof the sheriff did on January 10, 1952, release the attachment pursuant to instructions from Mr. Armstrong and that no property of appellant was thereafter levied upon under the writ. Although the record shows that on December 4, 1952, appellant unsuccessfully moved the trial court to discharge the writ upon giving an undertaking in lieu of the $8,500 under section 554, it does not disclose that the writ of attachment was ever discharged prior to June 20, 1956.
 Concerning the manner in which the substitution of security was made on January 10, 1952, it is undisputed that in December of 1951 appellant, negotiating for the sale of the hammer for $15,000, first discovered the existence of the lien when the company which held it in storage refused to deliver it to the buyer because of the attachment. In order that the lien could be removed and the sale consummated, appellant *360 immediately contacted his counsel, Mr. Hix, who talked to the buyer and then started negotiations with Mr. Armstrong for the release of the hammer. He told him that appellant was "going to deposit cash instead of a bond," and when Mr. Armstrong asked Mr. Hix if he was going to deposit the money with the clerk or the sheriff, the latter replied he would "just as leave deposit the money with him (Mr. Armstrong)," if it was all right with him. He agreed to this and suggested that Mr. Hix obtain a cashier's check payable to both counsel. Relative to how it was to be held, Mr. Armstrong said "Well, I don't care. You can hold it or I can hold it. It doesn't make any difference to me either." Thereafter, Mr. Hix secured the cashier's check payable to both counsel, endorsed it, and delivered it to Mr. Armstrong with the oral understanding the lien on the hammer would be released. This, together with the disposition of the check upon termination of the cause was set forth in a brief letter dated January 10, 1952, signed by both counsel and delivered with the check. Thereafter, but on the same day, Mr. Armstrong instructed the sheriff to release the hammer, which he did.
 Several conclusions are apparent from this evidence--that when, before the trial of the cause, the $8,500 was substituted by appellant for the hammer held by the sheriff, it was intended by both counsel that the deposit of the money and the release of the hammer be effected under section 540, even though counsel instead of the sheriff held the check; that when the hammer was released in exchange for the deposit as security for whatever judgment may be rendered against defendant, no provision was made for the discharge of the writ itself; that when the agreement between counsel was entered into and the deposit was made, the hammer was still under attachment and the check actually was in the possession of Mr. Armstrong before the hammer was released by the sheriff; and that appellant would not have given Mr. Armstrong his $8,500 for security had the hammer not been attached under the writ and had he not needed its release in order to consummate its pending sale. In connection with the evidence in the record concerning the reason appellant made the deposit, had respondent claimed contrary to that proved, it made no effort to establish it for the Pacific Indemnity Company offered no witnesses, no evidence and no defense at the trial.
 [8] "While under the terms of the attachment undertaking the obligors agree to indemnify the prevailing attachment defendant for all damages he may sustain as the result of the *361 attachment, they are liable only for the actual loss proximately caused by the attachment or likely to result therefrom in the ordinary course of things." (6 Cal.Jur.2d, Attachment and Garnishment,  155, p. 68; Elder v. Kutner, 97 Cal. 490 [32 P. 563]). [9] Accordingly it has become the rule that a defendant is entitled to recover from a surety, under the terms of the bond, the damages he sustained by reason of the detention of his money under an attachment, and the reasonable value of the loss of use of money is the legal rate of interest (7 per cent per annum), during the period of detention (Gray v. American Surety Co., 129 Cal.App.2d 471 [277 P.2d 436]). We believe the same rule applies in a situation such as the one at bar in which the money on deposit with counsel, though not actually physically held by the sheriff under levy of attachment, was deposited for the sole purpose of effecting a release of personal property levied upon under writ of attachment, and held in lieu thereof under section 540 as security for the payment of any judgment recovered. As a direct result of the levy on the hammer, appellant was compelled to and did deposit the $8,500 with Zoeller's counsel in order to obtain a release of the same so he could sell it. The loss of use of the money detained by counsel was not only forseeable but the proximate result of the attachment levied on the hammer. That money might be deposited in lieu of the hammer under attachment and appellant would be deprived of its use during the time it was held were foreseeable, is borne out by the existence of section 540 permitting the substitution, with which, we must assume, the respondent bonding company was familiar. The respondent's bond enabled Zoeller to secure the issuance of the writ of attachment which, in turn, authorized the sheriff to attach and hold the hammer. To consummate the sale of the hammer which appellant negotiated without knowledge of the attachment, he had to secure its release which could be done in the time available only by giving an undertaking or depositing the $8,500. While the money was withheld from him, although not under levy of attachment, he was deprived of its use, which constituted a "loss resulting from the levy" (Ideal Heating Corp. v. Royal Indemnity Co., 107 Cal.App.2d 662, 664 [237 P.2d 521]), for which the surety on its attachment undertaking is liable. We hold that appellant is entitled to recover the legal rate of interest on the amount detained.
 [10] Respondent argues that appellant voluntarily entered into an independent agreement to deposit the money with *362 counsel instead of the sheriff or other officer specified by section 540 and because of this consent to its deposit with a private stakeholder, the loss of use of the funds was a proximate result of the agreement between counsel and not of the attachment. Having already held that the chain of events set in motion by the issuance and levy of the writ of attachment directly resulted in the loss of use of money during the time it was held by counsel, we have in effect also determined that the fact it was held by counsel instead of the sheriff under the instant circumstances has no bearing on the issue of proximate cause. This is not an action against the sheriff for improperly releasing the hammer, or a suit to recover on defendant's bond or his funds on deposit (Glogau v. Hagan, 103 Cal.App.2d 828 [230 P.2d 392]; Kast v. California Corp., 185 Cal. 450 [197 P. 339]). It cannot be said that such a deposit was not a foreseeable consequence of the attachment because not only does section 540 provide for the detention of such funds, but the evidence discloses that it was the clear intent of both counsel to effect the deposit and secure the release under its provisions; and the fact that the money was held by a private party instead of the sheriff is not under the present circumstances a departure from the statutory procedure substantial enough either to affect the foreseeability of the consequences of the original attachment, or to preclude recovery on the surety bond, especially where no prejudice resulted. That Mr. Armstrong, the stakeholder, represented respondent during the trial of the within action attests the confidence it had in his integrity and reliability, and respondent has pointed out no prejudice flowing to it because of the technical deviation claimed.
 Any argument that the loss sustained by appellant was the result of a voluntary agreement to make the deposit, to which he willingly consented for which respondent could not be liable, is entirely unrealistic and completely ignores the procedure and purpose of the remedy of attachment. There is little consent or voluntary accession to a substitution of security in a situation in which it must be made in order to salvage the sale of the property held under attachment. The deposit of the $8,500 with counsel representing his opponent can hardly be said to be the result of the exercise of a free and voluntary act on the part of appellant as would deprive him of the right to recovery of damages by reason of the attachment. In effect it was the result of a normally coercive, though cooperative, attitude manifested by Mr. Armstrong *363 in a fair and proper effort to protect the rights of his client (Heine v. Wright, 76 Cal.App. 338, 343 [244 P. 955]).
 [11] In support of appellant's last contention that the attorney's fees of $200 allowed as an item of damage is inadequate, he cites Reachi v. National Auto. & Cas. Ins. Co., 37 Cal.2d 808 [236 P.2d 151], for the proposition that legal expenses incurred in the defense of the main action are recoverable as damages for wrongful attachment if the property can only be released by winning the suit.
 The record before us not only fails to disclose a discharge of the writ prior to June 20, 1956, but shows that on December 5, 1952, appellant unsuccessfully moved the trial court to discharge the same upon giving an undertaking in lieu of the $8,500 under section 554. Subsequently, he recovered judgment upon a trial on the merits in the main case, which was affirmed on appeal. Although it is true that the hammer was released by the sheriff under the writ, the $8,500 was deposited with counsel on January 10, 1952, and no funds were held under actual levy, it can hardly be intelligently argued that the money was not deposited by reason of the attachment, although held by counsel instead of the sheriff. We are not aware of the trial court's reason for denying the December 5, 1952, motion to discharge but whether the writ of attachment was still in full force and effect, never having been discharged, and was not discharged until appellant prevailed in the main action, it is nevertheless clear that appellant had to win the principal case in order to secure the release of the funds held by reason of the attachment. The situation at bar falls within the reasoning of the court in Reachi v. National Auto. & Cas. Ins. Co., supra, 37 Cal.2d 808, and we believe is governed by the rule laid down in that case. Faced as here with the provisions of section 539 and an undertaking guaranteeing payment of all costs "and all damages which they, or any of them may sustain by reason of said attachment," and the settled rule "that the measure of damages in an action on an attachment bond is the actual expense and loss necessarily and proximately caused by the levy" (p. 811), the court held that there is no support either in logic or legal principle for the position that the attorney's fees incurred in the defense of the principal suit can never be regarded as having been proximately caused by the levy of a writ of attachment regular on its face, not subject to a motion to vacate or dissolve it. Although the property of appellant in the Reachi case was actually under the lien of the *364 attachment wrongfully obtained, we believe the same principle should apply under the circumstances of the instant case in which appellant's funds were held as a proximate result of the levy of the writ on other property owned by him. It was as necessary for appellant herein to win the principal case to effect a release of his money as it was for Reachi to win his main case to clear title to the real property held under the lien and defeat the writ.
 The lower court awarded $200 for fees for services of appellant's counsel up to the time the hammer was released from attachment on January 10, 1952, but denied recovery of fees for legal services rendered by him in the defense of the main action. Under the principle of Reachi v. National Auto. & Cas. Ins. Co., supra, 37 Cal.2d 808, 811, appellant is entitled to them as an item of damage he sustained by reason of the attachment.
 Having held that the loss of use of the money detained by Mr. Armstrong is damage suffered by appellant by reason of the attachment and he is entitled to be compensated therefor by interest at the rate of 7 per cent per annum from January 10, 1952, to June 20, 1956, which amounts to $2,637.58; and that in addition to the $500 allowed by the trial court for loss of credit and not questioned by either party, and the $200 appellant has been awarded, he is entitled to attorney's fees for services rendered in the defense of the main action, it appears that the cumulated amount of these damages exceeds the $2,500 limit of respondent's liability under its bond. Therefore, appellant is entitled to have judgment in the sum of $2,500 with interest at 7 per cent per annum from the date the action was filed on August 2, 1956.
 The judgment is reversed and the case remanded to the trial court with instructions to enter judgment accordingly.
 Wood, P. J., and Fourt, J., concurred.
