0

I need help with storing a bytes value.

contract StoreBytes {
    bytes public addresses;
    function addMe() external {
        // TODO Add msg.sender to addresses.
    }
}

What I want is that msg.sender is added to addresses, basically addresses to be a chain of addresses. Example: If 0x0000000000000000000000000000000000000000 calls addMe() and then 0x1230000000000000000000000000000000000000, addresses would look like: 0x00000000000000000000000000000000000000001230000000000000000000000000000000000000.

I don't know why I can't fix this :D.

I really appreciate your help.

1
  • Why would you take this approach, as opposed to something more standard like making addresses and array of addresses?
    – Alex Otsu
    Feb 14, 2022 at 5:43

1 Answer 1

1

Agree with Alex that what you're asking is a bit suspicious and there may be a better way to achieve whatever you're doing. But since this is a Q/A forum and not a product review...

try:

abi.encodePacked(addresses, msg.sender)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.