Before the writ is issued, the plaintiff shall give a written undertaking with sufficient sureties to the effect that, if the defendant recovers judgment, the plaintiff will pay all costs that may be awarded to the defendant and all damages that the defendant may sustain by reason of the attachment, not exceeding the sum specified in the undertaking, and that, if the attachment is discharged on the ground that the plaintiff was not entitled to it under AS 09.40.010 - 09.40.110, the plaintiff will pay all damages that the defendant may have sustained by reason of the attachment, not exceeding the sum specified in the undertaking. The sum specified in the undertaking shall be equal to the amount claimed by the plaintiff, but not less than $100.