Skip to content

Instantly share code, notes, and snippets.

@nerderlyne
Created June 20, 2024 10:03
Show Gist options
  • Save nerderlyne/51793c9cf46c54960d39ea8aa132fc61 to your computer and use it in GitHub Desktop.
Save nerderlyne/51793c9cf46c54960d39ea8aa132fc61 to your computer and use it in GitHub Desktop.
calculate key, slot and value
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
contract MADV {
function getKey(address validator) public pure returns (uint192) {
return uint192(uint160(validator));
}
function getSlotAndValue(address validator) public pure returns (bytes32 slot, bytes32 value) {
slot = bytes32(abi.encodePacked(getKey(validator)));
value = bytes32(abi.encodePacked(validator));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment