Welcome to MSBD5017
This section will introduce you to the basics of our course and guide you through your first steps in MSBD5017.
Your First Smart Contract: Hello World
Let's begin with a simple yet fundamental example in smart contract development - the "Hello World" program. This example will help you understand the basic structure of a smart contract.
What We're Building
We'll create a smart contract named HelloWorld
that has a single function hello
. When called, this function will return a greeting message.
The Code
Feel free to experiment with the code and see how your changes affect the output.
TipHere are a few tips to help you get started:
- The code is automatically compiled as you type.
- If you want to manually compile, press
Cmd + S
(on Mac) orCtrl + S
(on Windows/Linux).- Try changing the return message in the
hello
function and see how it updates the output!
Understanding the Code
Let's break down what's happening in this smart contract:
contract HelloWorld
: This line declares a new smart contract named "HelloWorld".function hello() public pure returns (string memory)
: This defines a function named "hello" that:- Is
public
, meaning it can be called from outside the contract. - Is
pure
, indicating it doesn't modify or read the contract's state. - Returns a
string
.
- Is
return "Hello, World!";
: This is the actual greeting our function returns.
What's Remix IDE?
Remix IDE is a free, online tool for writing and testing smart contracts. It's great for beginners learning Solidity, the language of Ethereum smart contracts.
Our Approach
In this course, we'll use a simple built-in code editor for challenges. Why?
- It's easy to use
- You can focus on learning, not tools
- Everything you need is right here on the page
But don't worry - the skills you learn here will work in Remix too (and we will use Remix later in the course).
What's Next?
As you grow, you might want to try more advanced tools like hardhat
. We'll cover that later.
For now, let's start coding!