Does a contract address have to specified to watch for an event? Or, can I register an event handler for every time contracts of a certain type are transacted?
Events are stored in the transaction log associated with the address of the deployed contract instance. You need to know the addresses of the contracts you want to listen to and cannot simply listen to the whole blockchain looking for an event of some class produced by a contract of some class. Indeed, even if it were possible, you probably wouldn't want to do this since multiple Dapps may be using contracts with identical signatures for completely different purposes, so there the events would not have the same meaning.
You could however work around it by:
- A register contract - holds the addresses of all contracts of a specific type within your Dapp. You then register event handlers to watch all registered contracts.
- A common logging contract - sub contracts call a function on this singleton service in order to raise events. Your event handler just needs to watch this contract.