Actors & Actions
Something i like to do when looking at code, is making a model of it in terms of "Subjects", "Objects", and "Verbs" or "Actions".
First, as the "Subjects", we have people interacting with the smart contract. In Blockchain land, we call these "Accounts", identified on the network by an address
1.
If we map out the contract on a high level, we can identify:
- Subjects:
ContractOwner
,PunkOwners
,Buyers|Bidders
- Objects:
Punks
,Offers
,Bids
- Actions:
assign
,transfer
,offerForSale
,buy
,withdrawEther
,bid
,acceptBid
,withdrawBid
LarvaLabs is the ContractOwner
. Punk Owners
and Buyers
interact via Offers
and Bids
.
We can rephrase the above to the following:
Entities can...
- get punks assigned2
- transfer punks
- offer punks for sale
- buy punks
- make, withdraw, and accept bids on punks
- withdraw sale proceeds
With this general understanding of the marketplace, we can finally start diving into the actual code for it!
Footnotes
- Most blockchains use private-public key cryptography to enable self governed participation in the network. Key pairs controlled by entities (e.g. people). ↩
- The early story of CryptoPunks is actually split into two contracts: The initial claim, and the reassignment to the original claimers after a bug was found in the first version of the contract. ↩