Events
Next up, we have an interesting data type: "Events". With all kinds of computation happening onchain, we need a way to inform the outside world of relevant changes to our state, so that applications (like the CryptoPunks Website) can correctly display what's happening on the blockchain.
event PunkTransfer( address indexed from, address indexed to, uint256 punkIndex);The above event declaration reads as follows:
- This contract can emit a
PunkTransferevent with three data points attached:fromwhom the punk was transferred (account address),towhom it was transferred,- and which punk was transferred (via its 0-9,999
punkIndexidentifier)".
Searching for the events in the contract we will see it used or "emitted" when a punk is sold or sent from wallet to wallet.