While reading the whitepaper and the wiki, as a programmer I tried to figure out what exactly happens in the contract examples. I thought it might be a nice idea to annotate the examples so we and other people can learn from it.
Lets take the one from the wiki
below ('A real example - simple forwarding contract to create a transferable account
I made a start with the annotations (and assume '//' starts a comment). I made the parts I don't fully understand bold. I hope someone can clarify these parts.
// If the transaction value is less then 200 times the base fee; stop.
if tx.value < tx.basefee * 200:
// Otherwise get the stored contract sender (see below) at the end
// of the contract storage. (why use the large array index?)
// If that value is not the sender, and the sender is specified
// (I guess that is wat is being checked, but could this ever
// not be the case?); stop
a = contract.storage[2^256 - 1]
!(tx.sender == a) && (tx.sender > 0):
// If the first input is some big number, store the data in the second
// input in the contract storage (what is the purpose of this?).
if tx.data == 2^160:
contract.storage[2^256 - 1] = tx.data
// If the sender has not been set before; store the sender of the
// transaction at the end of the contract storage array.
if a == 0:
contract.storage[2^256 - 1] = tx.sender
// Create a new transaction that (does what?)
o = array()
i = 0
while i < tx.datan - 1:
o[i] = tx.data[i+1]
i = i + 1
mktx(tx.data,tx.value - tx.basefee * 250,o,i)