# Intelligence Providers

Manage viewing keys and decrypt SRC20 event data. Viewing keys are 32-byte AES-256 keys stored in the [Directory](https://docs.seismic.systems/clients/python/abis/directory) genesis contract that allow holders to decrypt Transfer and Approval event amounts.

## Functions

| Function                                                                                                                              | Returns             | Description                                     |
| ------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ----------------------------------------------- |
| [`register_viewing_key`](https://docs.seismic.systems/clients/python/src20/intelligence-providers/register-viewing-key)               | `HexBytes`          | Register a viewing key (shielded write)         |
| [`get_viewing_key`](https://docs.seismic.systems/clients/python/src20/intelligence-providers/get-viewing-key)                         | `Bytes32`           | Fetch your viewing key (signed read)            |
| [`check_has_key`](https://docs.seismic.systems/clients/python/src20/intelligence-providers/check-has-key)                             | `bool`              | Check if address has a key (public)             |
| [`get_key_hash`](https://docs.seismic.systems/clients/python/src20/intelligence-providers/check-has-key)                              | `bytes`             | Get `keccak256` hash of address's key (public)  |
| `compute_key_hash`                                                                                                                    | `bytes`             | Compute `keccak256(viewing_key)` locally (pure) |
| [`watch_src20_events_with_key`](https://docs.seismic.systems/clients/python/src20/intelligence-providers/watch-src20-events-with-key) | `SRC20EventWatcher` | Watch events using an explicit viewing key      |

All functions except `compute_key_hash` have async variants prefixed with `async_`.

## Example

```python
import os
from seismic_web3 import PrivateKey, Bytes32, SEISMIC_TESTNET
from seismic_web3.src20 import register_viewing_key, get_viewing_key

pk = PrivateKey.from_hex_str(os.environ["PRIVATE_KEY"])
w3 = SEISMIC_TESTNET.wallet_client(pk)

# Register a viewing key
viewing_key = Bytes32(os.urandom(32))
tx_hash = register_viewing_key(w3, w3.seismic.encryption, pk, key=viewing_key)
w3.eth.wait_for_transaction_receipt(tx_hash)

# Fetch it back
fetched = get_viewing_key(w3, w3.seismic.encryption, pk)
assert fetched == viewing_key
```

## See Also

* [Event Watching](https://docs.seismic.systems/clients/python/src20/event-watching) — Watch and decrypt SRC20 events
* [Types](https://docs.seismic.systems/clients/python/src20/types) — Decrypted event data structures
* [Directory ABI](https://docs.seismic.systems/clients/python/abis/directory) — Low-level ABI and contract address
