A person to whom a debt is due for labor performed in constructing a building, sewer or drain, or water works or other public works owned by a city or town, under a contract with any person having authority from or rightfully acting for such city or town in furnishing such labor, shall have a right of action against such city or town to recover such debt if, within thirty days after he ceases to p