CRYPTO NEWS

Is storing two copies of a mapping of a struct cheaper than storing one copy and two mappings of integer?

I am working on a smart contract that stores transactions of complicated objects (a struct with 11 properties including strings, addresses, boolean, and uint256). I want each user to have access to two separate lists, the transactions they sent, and the transactions they received. I can think of two feesible ways to do this.

  1. Create two mappings, one maps user addresses to transaction objects they sent, and one that maps user addresses to transaction objects they received. This way, each transaction object is stored twice and seems a bit inefficient.

  2. Create a mapping from a uint256 index to transaction objects. Then, create two mappings, one from user address to the indices of objects they sent, and one to the indices of objects they received. This way, each transaction objects are only stored once. However, I have to store two additional mappings from addresses to uint256, so 3 mappings in total.

From what I have heard, packing multiple properties into one struct can be very memory efficient. So, which way is cheaper?

Is storing two copies of a mapping of a struct cheaper than storing one copy and two mappings of integer?

Shopping cart
There are no products in the cart!
Continue shopping
0