downloadget_viewing_key

Fetch your viewing key from the Directory contract

Fetch your viewing key from the Directory genesis contract using signed read authentication.

Signatures

def get_viewing_key(
    w3: Web3,
    encryption: EncryptionState,
    private_key: PrivateKey,
) -> Bytes32

async def async_get_viewing_key(
    w3: AsyncWeb3,
    encryption: EncryptionState,
    private_key: PrivateKey,
) -> Bytes32

Parameters

Parameter
Type
Description

w3

Web3 / AsyncWeb3

Web3 instance with Seismic support

encryption

Encryption state from wallet client

private_key

Signing key for authentication

Returns

Bytes32 — 32-byte AES-256 viewing key.

Raises ValueError if no viewing key is registered for the caller's address.

Example

Notes

  • Uses a signed read (getKey()) so that msg.sender is authenticated — only the key owner can retrieve it

  • Typically called internally by watch_src20_events() to fetch the key before polling

See Also

Last updated