This is not viable without storing custom NBT data in the chest item because a player can have more than 27 slots.
1) create the chest item `set {_item} to 1 chest named "whatever"`
2) loop victim's inventory when they die
3) `add full nbt of loop-value to {_items::*}`
https://skripthub.net/docs/?id=10689
4) after the loop, `set compound list tag "minecraft:custom_data;DeathItems" of nbt of {_item} to {_items::*}
This will store the items inside the chest, now for the claiming part.
1) Inside the right click (or place) event, check `if nbt of player's tool has tag "minecraft:custom_data;DeathItems"`
if this passes that means its an item generated by our code.
2) get the list of items (as an nbt compound) `set {_items::*} to compound list tag "minecraft:custom_data;DeathItems" of nbt of player's tool`
3) give the items, `drop (item from nbts {_items::*}) at player`
the reason we use `drop` over `give` is because the items might disappear if the player doesn't have enough inventory space.
Try doing it yourself and if it doesn't work send your attempt!