Should a blessing be recited when building a fence around a roof?
It is a positive command for a person to make a fence on his roof as it says in the verse “And you shall make a fence for your roof.” Anyone who leaves his roof without a fence has nullified a positive command and has transgressed a negative command as the verse says “Do not spill blood in your home.”
Which roofs are obligated in having a fence? A fence is only obligated to be established to a roof which its roof space is commonly used, and contains a 4×4 Amos space [196 x 196 cm.]. [It is disputed if each side, both length and width must contain a four Amah space, or if 4 square Amos suffices.]
Is a blessing said upon doing an action to prevent danger? The general rule is that whenever one does something to remove danger a blessing is not recited.
Saying a blessing:
Some Poskim rule that a blessing is to be recited upon building a fence around one’s roof to prevent danger and fulfill the Mitzvah. It is only to be recited if the roof is truly obligated in a fence, such as that it has a space of more than 4×4 Amos [196 x 196 cm.] and is commonly used, as stated above, and will be ten Tefach high and the roof does not already contain a ten Tefach high fence or wall. The Nussach of the blessing is “Baruch Ata Hashem Elokeinu Melech Haolam Asher Kidishanu Bemitzvosav Vetzivanu Laasos Meakah.” The blessing is to be said when the final part of the fence is erected. Other Poskim, however, rule that a blessing is never to be recited upon putting up a fence around one’s roof. [Practically, the accepted practice is to say the blessing if the above conditions are fulfilled.]
Shehechiyanu: Some Poskim rule the blessing of Shehechiyanu is to be recited upon performing a Mitzvah for its first time, and hence when a fence is being put up for the first time, the blessing of Shehechiyanu is to be recited. However, other Poskim argue that one never says the blessing of Shehechiyanu upon performing a new Mitzvah and therefore no blessing is to be said upon putting up a fence for the first time.
Is the blessing to be said even if the fence is installed by a worker?
The blessing is to be said by the owner of the home, even if it is installed by a worker, including a gentile. However, this only applies if the worker is paid by the day or hour. If, however, he is paid for the job, then if he is a Jew, the Jewish worker is to say the blessing [of Al Asiyas Meakah], and if he is a gentile, a blessing is not to be recited.
 Devarim 28:8
 Admur Shemiras Guf Vinefesh Halacha 1; Michaber 427:1; Rambam Rotzeiach 11:1; Sifri Ki Seitzei 229
 Devarim 22:8
 Admur Shemiras Guf Vinefesh Halacha 1; Michaber 427:6; Rambam Rotzeiach 11:3; Sifri Ki Seitzei 229
 Admur Shemiras Guf Vinefesh Halacha 1; Smeh 427:2 and 5
 Admur ibid; Smeh 427:2 and 5
 Admur ibid; Michaber 427:2; Sukkah 3a
 So is debated in regards to Mezuzah [See Michaber Y.D.D 286:13 and Shach 286:23] and the same law follows regarding Meakah. [Minchas Chinuch 546:6; See Aruch Hashulchan C.M. 427:1; Maharsham 2:265]
 Admur 181:2; Rambam Brachos 11:4; M”A 4:13; Peri Megadim 4 A”A 13; Elya Raba 4:8
 See Pischeiy Teshuvah 427:1; Aruch Hashulchan C.M. 427:10
 Rambam Brachos 11:8, brought in Pischeiy Teshuvah ibid; Bahag Mezuzah 26; Sheilasos Rav Achaiy Parshas Eikev 145; Semag 27; Or Zarua 1:140; Siddur Rasag p. 101; Baal Haittur Tzitzis 3:2; Tamim Deim 179 in name of Halachos Pesukos; Kneses Hagedola O.C. 585; C.M. 427; Chayeh Adam 15:24; Machaneh Efraim Shluchim 11; Rav Akiva Eiger C.M. 427; Chasam Sofer O.C. 54; Sefer Haprdes 9; Sdei Chemed Asifas Dinim Brachos 16 that so is implied from majority of Poskim; Pnei Yitzchak Brachos 182; Sdei Haretz 3 C.M.; Rav Poalim 2:36 that so is the custom in Bagdad; Mentioned in Likkutei Sichos Ki Seitzei 2 p. 89 and Igros Kodesh
 The reason: As the Mitzvah of making a fence is in addition to the Mitzvah of preventing blood from spiling in one’s home, and hence it deserves its own blessing. [Rebbe ibid; See Minchas Chinuch 546:2]
 Rambam ibid
 Chasam Sofer O.C. 54; See Sdei Haretz 3:20
Other opinions: Some Poskim rule that the blessing is to be said at the beginning, just as is done regarding Biur Chametz. [Baal Haittur Tzitzis 3:2]
 Rokeiach 366; Implication of Michaber and Admur who omit the blessing; Aruch Hashulchan C.M. 427:3 that so is evident from some Rishonim and 427:10 in name of Tamim Deim 179 in name of Poskim
 The reason: As even gentiles were commanded in this Mitzvah, and a blessing is only recited over a Mitzvah that Jews alone were commanded in. [Rokeiach ibid]
 Taz 22:3; Olas Tamid 22:1; Chasam Sofer 55; Rama Y.D. 28:2 regarding Kisuiy Hadam; Tevuos Shur 28, brought in P”M Y.D. 28 S.D. 5; Rambam Brachos 11; Rokeiach 371 in name of Rivak Mishepira; Opinion in M”B 22:1 regarding Tzitzis; Biur Halacha 22:1 “Kanah” in name of Gr”a
 Rambam ibid 11:9
 Shach Y.D. 28:5; Tosafus Sukkos 46a; Ran Chulin 88; Rashba 126; Peri Chadash 28; Tzevi Latzadik 28; M”A 22:1; Mamar Mordechai 22:1; Machazik Bracha 22:2 that so is opinion of Michaber 22:1 and that so is the custom not to recite Shehechiyanu on Tefillin; Chayeh Adam 62:10; M”B 22:2; Kaf Hachaim 21:2 in name of many Poskim; Maharik Shoresh 128 regarding wedding; So rule regarding Tzitzis: Michaber 22:1; Admur 22:1; Baal Haittur; Mahariy Abuhav, brought in Biur Halacha ibid
 Nishmas Adam 15:3, brought in Pischeiy Teshuvah ibid; Aruch Hashulchan C.M. 427:3
The reason: As the sages only instituted to recite the blessing of Shehechiyanu by a Mitzvah that contains joy. [Shach ibid in name of Tosafus ibid] Alternatively, the reason is because it does not come from time to time. [Shach ibid in name of Ran ibid] Alternatively, by Tefillin the reason is because one is meant to put it on already as a child, when one cannot yet say Shehechiyanu due to the lack of obligation, and therefore the sages never instituted this blessing to be said by Tefillin, even when worn for the first time by an adult. [Tzevi Latzadik ibid] Alternatively, the reason is because the Simcha by a Bar Mitzvah only comes from the future knowledge of the successful indoctrination of the child to become a servant of G-d, and is not readily apparent. [Rebbe ibid in Hisvadyus 5748]
 Machaneh Efraim Shluchim 11, brought in Pischeiy Teshuvah ibid and referenced to in Rav Akiva Eiger 427
Other opinions: Some Poskim rule that the blessing may not be recited if the fence is erected by a gentile, and that furthermore, it is considered that he did not fulfill the Mitzvah, as a gentile cannot be appointed the Shliach of a Jew to do the Mitzvah. [Minchas Chinuch 546:3; Chikreiy Lev Y.D. 9]
 Rambam Brachos 11:13; Rav Akiva Eiger C.M. 427:1
 Kneses Hagedola 585; Pischeiy Teshuvah ibid
Other opinions: Some Poskim rule that the blessing is to always be recited by the owner even if the fence is erected by a contracted gentile, and certainly if it is erected by a contracted Jew. [Daas Kedoshim Y.D. 289:2; Aruch Hashulchan C.M. 427:3]