> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phylax.systems/llms.txt
> Use this file to discover all available pages before exploring further.

# Modified Key Discovery

> Discover mapping keys through transaction inputs and emitted logs

Modified key discovery describes how to identify mapping keys that changed during a transaction by using transaction inputs, emitted logs, and explicit storage-slot knowledge.

## Status

* [ ] Supported
* [x] Partially Supported
* [ ] Not Supported Yet

## Implementation Details

### Example Implementation

Protocol:

```solidity theme={null}
contract Protocol {
    mapping(address => uint256) public balances;

    function transfer(address to, uint256 amount) public {
        balances[msg.sender] -= amount;
        balances[to] += amount;
    }
}
```

Assertion:

```solidity theme={null}
function assertionUseCase() public {
    address[] memory modifiedKeys = getModifiedKeys(address(protocol), 0x0);

    int diff = 0;

    for (uint256 i = 0; i < modifiedKeys.length; i++) {
        // Here your code to check the modified keys
    }
}
```

## Example Use Cases

* Check invariants about total balances
* Check invariants about balances of specific addresses

## Implementation Patterns

* Use `FunctionCallInputs` to get the inputs of the function call and retrieve the modified keys.
* Use `getLogs` to get the logs of the transaction and retrieve the modified keys.
