DEV Community

Cover image for HelloWorld Smart contract
Seth Lawson
Seth Lawson

Posted on

HelloWorld Smart contract

This is a smart contract written in the Solidity language,
The contract contains a public “message” variable of type String, initially defined as “Hello, World!” when the contract is deployed.

The contract also has a public “setMessage” function that updates the value of the “message” variable with a new string passed as an argument.

memory is a data type in Solidity used to temporarily store variables when executing functions. It saves storage space by automatically clearing the data once the function has finished.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract HelloWorld {
    string public message;

    constructor() {
        message = "Hello, World!";
    }

    function setMessage(string memory _newMessage) public {
        message = _newMessage;
    }
}
Enter fullscreen mode Exit fullscreen mode

If you like the article and would like to support me, make sure to:

📑 View more content on my dev.to Profile

🔔 Follow Me: LinkedIn| GitHub | Twitter

🚀 Help me in reaching to a wider audience by sharing my content with your friends and colleagues.

Top comments (1)

Collapse
 
g33knoob profile image
G33kNoob

Keep spirit