Curriculum·Graduate·G301

Solidity Mental Models

Rubixi, 2016. Rubixi was a smart contract for a pyramid-style game whose developer had renamed the contract from an earlier name but had not renamed its constructor, the special function that runs once at deployment to set the owner.

Taught in G301-01 ›Source ↗

Start with lesson 14 lessons · about 2.2 hours · free account to read in full

Lesson 1 opens on

Rubixi, 2016

Rubixi was a smart contract for a pyramid-style game whose developer had renamed the contract from an earlier name, DynamicPyramid, but had left the constructor, the special function that runs once at deployment to set the owner, under the old name. In the Solidity of the time a constructor was identified only by having the same name as the contract, so once the contract was renamed to Rubixi the old-named function was no longer a constructor at all; it was an ordinary public function that anyone could call at any time. Because that function set the caller as the owner, any user could call it to make themselves the owner and then withdraw the fees the contract had collected.

The lessons

  1. G301-01A contract does what it says, not what you meantExplain that a deployed contract executes its literal code, not the author's intentionabout 33 min · opens on Rubixi, 2016
  2. G301-02Access control: who is allowed to call thisExplain that every privileged function needs an explicit, correct check on who may call itabout 33 min · opens on Audius governance takeover, July 2022
  3. G301-03It is live and adversarial the moment it deploysExplain that a contract on mainnet is live and public the instant it is deployed, finished or notabout 33 min · opens on Eminence (EMN), September 2020
  4. G301-04Immutable: one mistake can be permanent and totalExplain that a deployed contract is immutable, so a logic error cannot be patched after the factabout 33 min · opens on Akutars, April 2022