Skip to content

The Blockchain Messenger Implementation

In this project, you are going to implement a simple messenger functionality in a Smart Contract.

  1. Through the constructor make sure you write the address that deployed the contract to a variable
  2. Create a message-variable of the type string, that only the deployer-address can update
  3. Create a counter, to see how many times the variable was updated.

Sample Solution

Of course, you're not left in the dark.

Once you're done, feel free to compare it to my sample solution!

//SPDX-License-Identifier: MIT

pragma solidity 0.8.15;

contract TheBlockchainMessenger {

    uint public changeCounter;

    address public owner;

    string public theMessage;

    constructor() {
        owner = msg.sender;
    }

    function updateTheMessage(string memory _newMessage) public {
        if(msg.sender == owner) {
            theMessage = _newMessage;
            changeCounter++;
        }
    }
}

Last update: July 27, 2022