Factory pattern for tracking deployed contracts, best practice on Midnight?

Hey everyone :waving_hand:

I’m building a ticketing dApp where each event is its own deployed contract (using the event-tickets.compact pattern, one contract per event, no shared state between them).

On Ethereum we’d typically use a factory contract that deploys children and maintains an on-chain registry of all deployed addresses. This gives full trustless discoverability.

On Midnight I’m currently using an off-chain PostgreSQL backend as the registry — when an organizer deploys a contract, the frontend posts the contractAddress to the backend. Individual contract state (tickets issued, commitments) remains fully on-chain and trustless. Only the index lives off-chain.

My questions:

  1. Is there a recommended pattern for on-chain contract discovery on Midnight? e.g. a registry contract with a Set<Bytes<32>> of deployed addresses?

  2. Does Midnight support deploying a contract from within another contract (factory pattern)?

  3. Are there any indexer APIs or chain query tools that would let me discover all deployments of a given contract bytecode without a registry?

Happy to share the full contract if useful. Thanks!

1 Like