Q. What does a horse say to an insecure Web3? A. NAAAAY! Get ready for First Flight #7: Horse Store, another perfect opportunity to learn and grow!
Much of the NFT code was inspired by Huffmate
High - 100xp
Medium - 20xp
Low - 2xp
Starts: January 11, 2024 Noon UTC
Ends: January 18, 2024 Noon UTC
Neiiigghhhhhh
We are the equestrian lovers, and we LOVE all things horses! So we've created an NFT to commemorate our love of horses.
But, here is the thing, horses are fast and don't burn gas, but burn oats. So we wanted to make sure our codebase was hyper optimized, and to do so, we've written our contracts in Huff, a horse-themed assembly-like language so our code can be hyper-optimized and FAST.
πππππππππππππππππππππππππ
So, we wrote our codebase into 2 parts.
Every function in the solidity rendition has been re-written in huff. We wrote it in solidity first to get a better understanding of what the codebase should do, and then optimized it in huff. We consider the solidity written code to be our reference code, and the huff code to be our actual code.
This setup was inspired by the Seaport protocol, which did something similar with solidity reference contracts, and assembly actual contracts.
Our contracts are simple, they allow the following functionality:
mintHorse
: Allow anyone to mint their own horse NFT.feedHorse
: Allow anyone to feed a horse NFT. This will add a block.timestamp
to a mapping tracking when the horse was last fed.isHappyHorse
: Allow anyone to see if a horse is happy. A horse is happy if and only if they have been fed within the past 24 hours.We consider the horse happiness the most important aspect of the codebase, and our invariants can be defined as follows:
If horse X has been fed within the past 24 hours, horse X must be happy.
Horses must be able to be fed at all times.
Even if you don't understand Huff... Maybe you can write some tests...
For this codebase, we consider any of the following to be in-scope:
HorseStore.sol
HorseStore.huff
HorseStore.huff
functionality does not match HorseStore.sol
functionality, not including gas costs, or specific storage slots. Sending any X calldata to either contract should result in them being in the same state.git --version
forge
, cast
, and anvil
forge --version
and get an output like: forge 0.2.0 (f016135 2022-07-04T00:15:02.930499Z)
foundryup
huffc --version
and get an output like: huffc 0.2.0
git clone https://github.com/Cyfrin/2024-01-horse-store
cd 2024-01-horse-store
make
forge test
01bce4f0a2271c4105ee7c9121b27fe7973b0eaf
#-- HorseStore.huff
#-- HorseStore.sol
#-- IHorseStore.sol
0.8.20
None
Rank | Username | ||||
1 | s stefanlatinovic | 1166 | 5 (0) | 0 (0) | 1 |
2 | n | 1092 | 5 (0) | 2 (0) | 3 |
3 | c ceseshi | 1044 | 5 (0) | 1 (0) | 1 |
4 | H Honour | 1000 | 5 (0) | 0 (0) | 0 |
5 | 0 0x4non | 860 | 3 (0) | 2 (0) | 1 |
6 | P Poor4ever | 860 | 4 (0) | 1 (0) | 1 |
7 | f flokapi2 | 844 | 4 (0) | 1 (0) | 1 |
8 | T Turetos | 800 | 4 (0) | 0 (0) | 0 |
9 | 0 | 648 | 3 (0) | 1 (0) | 2 |
10 | 0 0x18a6 | 644 | 3 (0) | 1 (0) | 1 |
11 | V VicRdev | 644 | 3 (0) | 1 (0) | 1 |
12 | w wafflemakr | 604 | 3 (0) | 0 (0) | 1 |
13 | s | 604 | 3 (0) | 0 (0) | 1 |
14 | 0 0xloscar01 | 600 | 3 (0) | 0 (0) | 0 |
15 | C Coffee | 600 | 3 (0) | 0 (0) | 0 |
16 | K Kaiziron | 448 | 2 (0) | 1 (0) | 2 |
17 | T TorpedopistolIxc41 | 448 | 2 (0) | 1 (0) | 2 |
18 | j jerseyjoewalcott | 440 | 2 (0) | 1 (0) | 0 |
19 | b bigBagBoogy | 400 | 2 (0) | 0 (0) | 0 |
20 | R Ritos | 400 | 2 (0) | 0 (0) | 0 |
21 | E EloiManuel | 330 | 1 (0) | 1 (0) | 2 |
22 | A Aitor | 256 | 1 (0) | 1 (0) | 0 |
23 | K | 248 | 1 (0) | 1 (0) | 2 |
24 | C CloudTact | 204 | 1 (0) | 0 (0) | 1 |
25 | n | 204 | 1 (0) | 0 (0) | 1 |
26 | a azanux | 200 | 1 (0) | 0 (0) | 0 |
27 | L | 80 | 0 (0) | 2 (0) | 0 |
28 | a abhishekthakur | 44 | 0 (0) | 1 (0) | 1 |
29 | 0 | 40 | 0 (0) | 0 (0) | 0 |
30 | M Maroutis | 40 | 0 (0) | 0 (0) | 0 |
31 | G Gelato | 40 | 0 (0) | 0 (0) | 0 |
32 | O | 40 | 0 (0) | 0 (0) | 0 |
33 | D DarkTower | 40 | 0 (0) | 1 (0) | 0 |
34 | B | 14 | 0 (0) | 0 (0) | 3 |
35 | p | 8 | 0 (0) | 0 (0) | 2 |
36 | m mircha | 4 | 0 (0) | 0 (0) | 1 |
37 | t tamoghna | 4 | 0 (0) | 0 (0) | 1 |
38 | d ducky7 | 4 | 0 (0) | 0 (0) | 1 |
39 | Y Yovchev | 4 | 0 (0) | 0 (0) | 1 |
40 | t thenpuli | 4 | 0 (0) | 0 (0) | 1 |
41 | P Pelz | 4 | 0 (0) | 0 (0) | 1 |
42 | e eLSeR17 | 4 | 0 (0) | 0 (0) | 1 |
43 | 0 0xVinylDavyl | 4 | 0 (0) | 0 (0) | 1 |