Final

SpaceMuffin are great for kids, but an Amiral of your level needs a Spacecrypt Armada!

Project

Within the SpacecryptFactory contract, you should

  • Declare halfway as a function
  • Complete onlyOwner modifier so only the owner can access it
  • Create a public produce function that only the owner can call and increase numberOfSpacecrypts by a given numberOfUnits
  • Finally, in case you die in a Spacecrypt battle, declare transferOwnership, a public function that sets the owner to msg.sender

Obviously, it's a wild world out there and I've secured this contract with tests. Don't try to cheat on me.

Exercise
Correct!
False!

Loading...

Create your own spacecrypt factory down there
pragma solidity ^0.4.24; contract SpacecryptFactory { uint public timeout = 60; bytes32 public name = 'SuperCryptor 2000'; // I don't mind if you change the name uint public numberOfSpacecrypts = 0; // How many spacecrypts have been produced so far address public owner = ; // who should be the initial owner? // uint public halfway = timeout / 2; // Timeout may change, halfway should be a function modifier onlyOwner() { // what should you require? } /** produce function has one argument (the number of units to produce) * is public and restricted to the owner */ // transferOwnership has one argument (the new owner) and is public }

Hint

  • You are the one deploying the contract and want to be the owner. There is a msg attribute for it
  • Don't forget how modifiers are written, especially including code with _;
  • produce is restricted using onlyOwner
  • transfer ownership takes msg.sender and assign it to owner

Congratulations, you've been able to start production of Spacecrypt! Your plan to conquer the crypto space has started 😈

This contract has been inspired by Ownable.sol. It is a model to help you design Ownable contract in the future.