Encode-Club-Solidity-Foundations / Lesson-02

4 stars 7 forks source link

Lesson 2 - Building HelloWorld.sol in Remix

Coding HelloWorld.sol

Detailed contract structure

https://docs.soliditylang.org/en/latest/structure-of-a-contract.html

Code Reference

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;

interface HelloWorldInterface {
    function helloWorld() external view returns (string memory);
    function setText(string memory newText) external;
}

contract HelloWorld is HelloWorldInterface {
    string private text;

    constructor() {
        text = "Hello World";
    }

    function helloWorld() public view override returns (string memory)  {
        return text;
    }

    function setText(string memory newText) public override {
        text = newText;
    }
}

Contract interaction

Part 1

Clean code and documentation

References

https://docs.soliditylang.org/en/latest/natspec-format.html#natspec

Homework