先の回答者さんのコマンドは1.20.4以前のものなので1.21.10では動作しません。
1.21.10ならこうです。
インパルス 無条件 動力が必要
/execute as @p if items entity @s weapon.offhand iron_ingot run give @s emerald
チェーン 無条件 常時実行
/execute as @p if items entity @s weapon.offhand iron_ingot run item modify entity @s weapon.offhand {function:set_count,count:-1,add:1b}
これは左手に持っている鉄インゴットの数に関わらず正しく動作します。ただし、@pを使っている関係上コマンドブロックの近くに他のプレイヤーがいると正しく動かない可能性があります。
これはボタンだとどうしようもないので、近くに他のプレイヤーがいても正しく動作するようにしたいならボタンではなく看板コマンドを使う必要があります。
以下は看板コマンドを使う場合の例です。
/give @p oak_sign[block_entity_data={id:sign,is_waxed:1b,front_text:{messages:[{text:\u0026quot;[看板ショップ]\u0026quot;,color:yellow,bold:1b,click_event:{action:run_command,command:\u0026quot;execute if items entity @s weapon.offhand iron_ingot run give @s emerald\u0026quot;}},[{sprite:\u0026quot;item/iron_ingot\u0026quot;,bold:1b,color:white,click_event:{action:run_command,command:\u0026quot;execute if items entity @s weapon.offhand iron_ingot run item modify entity @s weapon.offhand {function:set_count,count:-1,add:1b}\u0026quot;}},{text:\u0026quot; × 1 → \u0026quot;},{sprite:\u0026quot;item/emerald\u0026quot;},{text:\u0026quot; × 1\u0026quot;}],[{sprite:\u0026quot;item/iron_ingot\u0026quot;,color:white,bold:1b},{text:\u0026quot;を左手に持って\u0026quot;,color:green}],{text:\u0026quot;右クリック!\u0026quot;,color:green,bold:1b}]}}]