Well-defined and uniform double-walled Cu7S4 nanoboxes with an average edge length of about 400 nm have been successfully synthesized by using Cu2O nanocubes as sacrificial template based on an inward replacement/etching method. The key step of the process involves repeated formation of Cu7S4 layer in Na2S solution and dissolution of the Cu2O core in ammonia solution for two consecutive cycles. Experiments show that the time of dissolving Cu2O core with ammonia solution plays a key role in the preparation of double-walled Cu7S4. The as-prepared samples have been characterized by X-ray diffraction, field-emission scanning electron microscopy, transmission electron microscopy and photoluminescence analysis. NH3 sensing properties of Cu7S4 nanoboxes with single and double walls have been investigated at room temperature with a simply adapted photoluminescence-type gas sensor. The results revealed that the double-walled Cu7S4 nanobox sensor exhibited enhanced performances such as higher sensitivity and shorter response time in ammonia gas sensing compared with the single-walled one.