1 Million Dollar Bet
Let's look at some of the benefits of smart contracts:
- Speed, efficiency, and accuracy: Once a condition is met (i.e., price of BTC < 1 million), the contract is executed immediately. There are no paperwork or manual errors involved, thus transferring the money from Srinivasan to Medlock without any hassle.
- Trust and transparency: The records of transactions are available to every participant of the network, the platform where the smart contracts are executed. As described, Smart Contracts are programs that need to run for them to be meaningful, and to run, they'll need resources that the World Computer, Ethereum, can provide.
- Security: No one can change the terms and conditions of the Smart Contract once they have been deployed to the Blockchain; it is not possible for anyone, let alone Srinivasan, to sneak up and change the bet amount from 1 million to 1 hundred dollars. The participants of the network will detect any malicious behavior.
The above example is one of the many applications where smart contracts can play an important role, let's look at some more examples to understand it better:
- Insurance: Smart contracts can automate the claims process and verify the validity of claims based on the data and evidence.
- Voting: Smart contracts can ensure secure and transparent voting by recording and verifying votes on a blockchain.
- Identity management: Smart contracts can store and manage personal data and credentials on a blockchain, allowing users to control their identity and access rights.
- Crowdfunding Campaign: Smart Contract can collect funds from backers and release them to the project creator when a specific goal is met. The program refunds the backers if the goal is not met by a deadline.

block
Let's go ahead and build a Hello World of Smart Contracts
Hello World.
Smart contracts are programs; one should choose a programming language to create one. We'll be using Solidity language to create our HelloWorld.sol contract.
1// SPDX-License-Identifier: MIT
2pragma solidity ^0.8.0;
3
4contract HelloWorld {
5 string public message;
6
7constructor() {
8 message = "Hello, World!";
9 }
10
11function getMessage() public view returns (string memory) {
12 return message;
13 }
14
15function setMessage(string memory newMessage) public {
16 message = newMessage;
17 }
18}
Let's understand each line of the code one by one:
- The contract is named HelloWorld. Note: contract is a keyword, just like class is a keyword in Java.
- It has a state variable message of type string that stores the greeting message.
- The constructor function is executed once during contract deployment. It sets the initial value of the message to "Hello, World!".
- The getMessage function is a public view function that allows other contracts or users to retrieve the value of a message.
- The setMessage function is a public function that allows other contracts or users to update the value of the message by providing a new string.
Deploy Smart Contracts
To deploy and interact with this smart contract, you must use a development environment, such as Remix IDE, or a framework like Truffle. These tools provide an interface to deploy the contract to a test network or the Ethereum mainnet and interact with its functions and state variables. This might look scary initially, but don't worry; I'll walk you through the process.

Remix Homepage
- Open your web browser and visit the Remix IDE website: https://remix.ethereum.org/
- Ensure that you have a compatible web browser like Chrome or Firefox.

Remix Create New File
- On the Remix IDE homepage, click on the file icon, or click on contracts and right-click to get the option shown in the above figure.
- Name the file with a .sol extension, for example, HelloWorld.sol

Remix Copy and Paste Hello World Content
- Copy and paste the HelloWorld content into the newly created file.

Remix Compile
- In the Solidity Compiler section of Remix IDE, select the appropriate version of Solidity for your contract (e.g., 0.8.0).
- Click the Compile HelloWorld.sol button to compile your smart contract code. Make sure there are no compilation errors.

Remix Select Environment
- In the Deploy & Run Transactions section, select the "Injected Web3" environment from the Environment dropdown if you have Metamask (Don't forget to switch to a test network). This will allow you to connect to your Ethereum wallet. If you don't have Metamask installed for some reason, simply select one of the Remix VM, e.g., Remix VM Shanghai. They will give you a disposable account with some test Ethers.
- Click on the "Deploy" button next to the HelloWorld contract.
- You'll see some logs in the Remix Terminal window containing these details with a green checkbox.

Remix Logs

Remix Interact
- After the contract is deployed, Remix IDE will display information about the deployment, including the contract's address.
- You can now interact with the contract using the available functions. In the Deployed Contracts section, expand the contract and access its functions.
- You can call the getMessage function to retrieve the greeting message or use the setMessage function to update it.

Remix Function
Congratulations! You have successfully deployed and interacted with your first smart contract using Remix IDE.
Thank you for taking the time to read my article.
References: