Notes I've assembled for myself during my journey of learning Solidity, some notes maybe incorrect as they are my own interpretation
Allow clients to keep track of things. IE: Sent transactions, End of transactions, etc.
event EventName(...args)
Declare an event within a contract to be used.
{
...
event Sent(address from, address to, uint amount);
...
}
EventName(...parameters)
Emit the event to notify observers.
{
...
function send() {
Sent(msg.sender, reciever, amount);
}
}
Register listeners to the event.
Constructor.EventName().Watch(param, param2, callback)
IE: Coin.Sent().watch({}, '', function(err, result)
Callback(err, result).
Result contains property args
which is a object containing the keys defined as the parameters in the declaration.
A complex data type that can map values to a datatype
Type: mapping
- Virtually initialized
- Every possible key exists, but not possible to obtain a list of all keys of a map, or list it's values
- Mapped to a explicit null value?
mapping(variable => type) [public] mapName
IE: mapping(addresses => uint) public balances
Accept it like a blackhole
- Globally shared, and readable by anyone participating in the network
- Create "transactions" to change the database - not done or not completely aplied
- Once performed, nothing else can alter it
- Always cryptographally signed by creator
- Time is linear, and blocked together ('chained together') -- 17s in Ethereum
- "Double-spend attack" - Transactions occuring in the network that both want to empty an account like a merge conflict.
- ✨ Don't worry because transactions are bundled into a block, and the second one will be rejected and not part of the block.
- order selection mechanism = Mining
- blocks with greater / longer chains are less likely to be reverted, and removed from the blockchain.
- ⏱ is your friend
- Completely ISOLATED access to network, filesystem, or other processes
- Sandbox
- Contracts are limited to one and another
- External accounts - public-private key pairs (human accounts)
- Contract accounts - controlled by code stored together with account
- Addresses are from creator address and # of transactions
- All accounts have a key-value store mapping storage: 256-bit words to 256-bit words
- All have Ether (in Wei) and are modified by sending transactions