代(か)わり ‘a substitute’ is a 名詞(めいし) that is used to convey when (B) is acting as a replacement or substitute for (A). The 格助詞(かくじょし) (case marking particle)
に will come after 代(か)わり, before a (B) statement will highlight who the replacement is, and possibly what they are doing.
As 代(か)わり is a noun, it may be used after the 連体形(れんたいけい) (attributive form) of any word.
-
俺(おれ)が社長(しゃちょう)に電話(でんわ)する代(か)わりに、お前(まえ)はお客(きゃく)さんに電話(でんわ)をしておいて。
In exchange for me calling the boss, can you call the client in advance?
あのプールは古(ふる)い代(か)わりに安(やす)い。
That pool is cheap, to substitute for it being old.
仕事(しごと)は大変(たいへん)な代(か)わりに楽(たの)しい。
Work is fun, in exchange for it being difficult.
私(わたし)の代(か)わりにやってください。
Can you do it in my place?
Occasionally, 替(か)わり ‘to exchange’ may be used instead of 代(か)わり ‘to substitute’. However, within the context of this particular grammar structure, there is little to no change in nuance.
代(か)わりに is often used at the beginning of sentences, simply to express a more preferable option for something. In these cases, it comes across as ‘rather than that, (A)’, or ‘instead, (A)’.
-
代(か)わりに行(い)ってくれない?
As a replacement, can you go for me?
代(か)わりにこれを持(も)って行(い)って。
Instead of that, can you go take this?