Events are basically a "chain" of - you may guess - important events. You can basically watch the events to see what happened on the contract. Imagine events like a log, a chain of things that happened. Events are customly made so developers chose what events to use. Best thing to do to understand them is look at the smart contract and at the events happening at that contract. Events are great for developers who want to only see specific things happening in a contract - maybe they don't care about approvals but want to see transfers only. For example let's take the CryptoKitties contract (I chose that because it has more events than regular ERC20 tokens):
Events:
https://etherscan.io/address/0x06012c8cf97bead5deae237070f9587f8e7a266d#events
Code:
https://etherscan.io/address/0x06012c8cf97bead5deae237070f9587f8e7a266d#code
Dec 11, 2020, 10:12 PM
structs however are a structure of variables, basically one variable being able to store multiple variables (like arrays but named).
Example:
mapping(uint => string) buildingName;
mapping(uint => address) buildingOwner;
mapping(uint => string) buildingAddress;
would be better as:
struct Building {
string name;
address owner;
string addr; // string address; Won't work! address is a reserved keyword
}
mapping(uint => Building) buildings;
Example:
mapping(uint => string) buildingName;
mapping(uint => address) buildingOwner;
mapping(uint => string) buildingAddress;
would be better as:
struct Building {
string name;
address owner;
string addr; // string address; Won't work! address is a reserved keyword
}
mapping(uint => Building) buildings;
(structures don't store variables tho, thus the name, structure)
Dec 11, 2020, 10:17 PM