SOCI4L

A list that grows

Step 1 of 4
0 of 2 goals

Keep them in order

The mapping from the last lessons cannot tell you how many entries exist, or what the third one was. Nothing iterates it.

Declare a list:

uint256[] public notes;

Then push onto it inside sign:

notes.push(note);
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

contract Guestbook {
    function sign(uint256 note) external {
    }

    function count() external view returns (uint256) {
        return 0;
    }

    function noteAt(uint256 index) external view returns (uint256) {
        return 0;
    }
}

Goals

The contract compiles
nothing to compile yet
Three notes are stored
the contract has not run yet

Contract storage

Write a contract and it will deploy itself here.