Unordered Key Set

close button

Part II

Implementing Delete

Aside from inserting crates, there should be a way to remove them as well.

Implement the delete function in your contract, and make it efficient! Ensure that getCrateIds() only returns non-deleted crates.

Note that after repeated insertions and deletions, getCrateIds() must still be gas efficient! If you are thinking about iterating over all crate ids and filtering out non-deleted ones, it will likely be too costly.

Your Task

Implement the deleteCrate(uint256 id) function to your Crates contract.

Make sure your other functions still work!

Run tests in Questplay

Submit work in Questplay

Even once organized, the innkeeper will eventually empty each crate, and needs a way to track this so he doesn’t end up with the same mess.