Mission 1
Enlist for project Alpha Centauri!
You pause for a moment, breathing in the crisp, recycled air of the space academy. A sense of pride stirs within you, paired with the eagerness to move on to the next mission. Your eyes wander to a poster hanging on the hallway wall nearby: it depicts a massive space station orbiting a ringed planet, with three moons gleaming in the distance. Bold text beneath the image reads: "Enlist for Project Alpha Centauri today!"
Smart Contract
In this mission you will be creating a smart contract to enlist for the outpost in Alpha Centauri.
1Environment Setup
Before you begin, make sure you are in the proper branch.
Clone the repository:
git clone https://github.com/kmjones1979/graphbuilders-basecamp mission-1-enlistNavigate into the project directory:
cd mission-1-enlistCheckout the branch:
git checkout mission-1-enlistInstall the dependencies:
yarn installStart your local blockchain:
yarn chain2Deploy Contract
(In a new terminal)
yarn deploy3Start Frontend
(In a new terminal)
yarn start4Starting Contract Code
The starting smart contract code for this mission is as follows:
contract Enlist {
mapping(address => bool) public isEnlisted;
function enlist() public {
require(!isEnlisted[msg.sender], "You are already enlisted");
isEnlisted[msg.sender] = true;
}
}This basic contract allows a wallet to enlist themselves. You can check the current enlistment of a wallet by using the "Debug Contracts" tab in the header and checking the isEnlisted mappings value for your wallet address. You can also call the enlist() function on that page as well.
5Add an event to track addresses which have enlisted
To complete this task, follow these steps:
- Navigate to
packages/hardhat/contractsand open the fileEnlist.sol - Add an event called
Enlistedthat will emit anaddress - Use the event by calling the
emitkeyword inside theenlist()function
6Deploy your changes:
yarn deploy --reset7✅ Success will look like this:
deployed at 0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6 with 283218 gasSince this will be a new contract that is deployed, you will need to enlist on the main page or using "Debug Contracts" tab. If you were successful, continue with the next part of the mission.