Intelligence Providers
Viewing key management and encrypted event decryption
Manage viewing keys and decrypt SRC20 event data. Viewing keys are 32-byte AES-256 keys stored in the Directory genesis contract that allow holders to decrypt Transfer and Approval event amounts.
Functions
Function
Returns
Description
compute_key_hash
bytes
Compute keccak256(viewing_key) locally (pure)
All functions except compute_key_hash have async variants prefixed with async_.
Example
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_keySee Also
Event Watching — Watch and decrypt SRC20 events
Types — Decrypted event data structures
Directory ABI — Low-level ABI and contract address
Last updated

