From 6470eb42049be67aa33e012d1dbcd3ff1df24ef8 Mon Sep 17 00:00:00 2001 From: bt3gl <1130416+bt3gl@users.noreply.github.com> Date: Sat, 24 Sep 2022 21:27:17 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=A3=20add=20some=20boilerplates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- master_solidity/boilerplates/hello-world.sol | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 master_solidity/boilerplates/hello-world.sol diff --git a/master_solidity/boilerplates/hello-world.sol b/master_solidity/boilerplates/hello-world.sol new file mode 100644 index 0000000..24bd164 --- /dev/null +++ b/master_solidity/boilerplates/hello-world.sol @@ -0,0 +1,32 @@ +// Specifies the version of Solidity, using semantic versioning. +// Learn more: https://solidity.readthedocs.io/en/v0.5.10/layout-of-source-files.html#pragma +pragma solidity ^0.5.10; + +// Defines a contract named `HelloWorld`. +// A contract is a collection of functions and data (its state). +// Once deployed, a contract resides at a specific address on the Ethereum blockchain. +// Learn more: https://solidity.readthedocs.io/en/v0.5.10/structure-of-a-contract.html +contract HelloWorld { + + // Declares a state variable `message` of type `string`. + // State variables are variables whose values are permanently stored in contract storage. + // The keyword `public` makes variables accessible from outside a contract + // and creates a function that other contracts or clients can call to access the value. + string public message; + + // Similar to many class-based object-oriented languages, a constructor is + // a special function that is only executed upon contract creation. + // Constructors are used to initialize the contract's data. + // Learn more: https://solidity.readthedocs.io/en/v0.5.10/contracts.html#constructors + constructor(string memory initMessage) public { + // Accepts a string argument `initMessage` and sets the value + // into the contract's `message` storage variable). + message = initMessage; + } + + // A public function that accepts a string argument + // and updates the `message` storage variable. + function update(string memory newMessage) public { + message = newMessage; + } +}