James Bachini

Hello World In Solidity

Hello World Solidity

Your first smart contract deployment represents a fundamental shift in how you think about software. Unlike traditional applications that run on centralized servers, smart contracts execute on a distributed network of thousands of computers worldwide. Once deployed, your code becomes permanent, transparent, and permissionless.

This immutability creates both opportunity and responsibility. Smart contracts have facilitated decentralized finance transactions, enabled the creation of non-fungible tokens, and powered entire ecosystems of decentralized applications.

Yet this same immutability means that bugs become permanent features, and poorly written contracts can lose millions of dollars in seconds.

Every successful blockchain developer began exactly where you are now, writing their first simple contract and watching it come alive on the network.


Let’s Start With Remix

Remix is an online IDE which has become a core part of the Ethereum DevX

It’s free to use and you can open it up in a web browser at https://remix.ethereum.org

The platform includes a built-in Solidity compiler that automatically checks your code for errors, suggests improvements, and provides detailed feedback about gas costs and potential vulnerabilities. Its integrated debugger allows you to step through contract execution line by line, understanding exactly how your code behaves on the blockchain.

Let’s go in and use the little new file icon in the left hand pane to create a new file. Call it HelloWorld.sol


Hello World Solidity Code

Here is the code we will be using for our smart contract

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

contract HelloWorld {
    string public greeting;
    
    constructor() {
        greeting = "Hello World!";
    }
    
    function setGreeting(string memory _greeting) public {
        greeting = _greeting;
    }
}

The first couple of lines set a licence and minimum compiler version. Then we get into the contract itself.

We are setting up a public string which will include a getter function. This means we can store a piece of text in the variable greeting and fetch it at any time.

The constructor() function runs once when the contract is first deployed and it sets the string.

The setGreeting() function can be called by anyone and it will change the string to something else.


Deploying Locally & To Testnet

Compile the contract first using CTRL + S

Then go into the deploy section and let’s deploy it locally

Click deploy and you’ll get an interface under Deployed Contracts in the bottom left.

You can click the blue greeting button which will return your text. You can also call setGreeting to update it.

This is useful for local testing but it’s still on your local machine and not running on a decentralized p2p network.

Let’s move it to testnet (same principle for mainnet)

We will need a wallet to pay for transaction fees. I recommend Metamask which is available here: https://metamask.io/

We will also need some Testnet tokens. At time of writing the most commonly used testnet is Sepolia and there are plenty of faucets where you can get free testnet eth to pay for transactions, try googling “sepolia tesnet faucet”.

Once you have some testnet ETH, let’s go back to Remix and the deploy tab.

Change the Environment setting in the top left to “Injected Provider – Metamask”. Make sure that Metamask is set to Testnet. And then click deploy again.

You should be asked to confirm a transaction and once confirmed you will have successfully deployed your contract to a decentralized network.


Interacting With Your Deployed Contract

Once deployment completes, your contract appears in the Deployed Contracts section at the bottom of the Deploy tab. Remix automatically generates an interface for interacting with your contract’s functions.

Click the dropdown arrow next to your contract address to reveal available functions.

The interface displays different colors for different function types. Blue buttons represent view functions that read data without modifying the blockchain state. Orange buttons indicate functions that create transactions and potentially modify state. Click the blue “getGreeting” button to call your contract’s greeting function. The interface displays the returned value below the button.

Test the state changing functionality by entering a new greeting in the text field next to “setGreeting” and clicking the orange button. MetaMask will prompt you to confirm this transaction since it modifies the blockchain state and requires gas fees. After confirmation, call “getGreeting” again to verify your new message was stored successfully.

The contract address appears at the top of the deployed contract interface. Copy this address and visit sepolia.etherscan.io to view your contract on the block explorer. Search for your contract address to see detailed information about your deployment transaction, including gas usage, block number, and transaction hash. This explorer view provides transparency into your contract’s on chain activity.


Beyond Hello World: Your Development Path Forward

Your successful Hello World deployment represents the foundation for more ambitious blockchain projects. Understanding deployment workflows, gas mechanics, and contract interaction patterns enables progression to increasingly sophisticated applications.

Decentralized finance protocols, non fungible token contracts, and decentralized autonomous organizations all build upon the same fundamental concepts demonstrated in your Hello World contract. State management, function visibility, access control, and event logging appear in virtually every smart contract, regardless of complexity.

The Remix environment that served you well for Hello World continues supporting advanced development. Its debugging tools, gas optimization insights, and integrated testing frameworks scale with your growing expertise. Many professional developers continue using Remix for rapid prototyping and educational purposes even after mastering more complex development environments.

Local development environments like Hardhat and Foundry offer additional capabilities for large scale projects, but they build upon the same deployment and interaction patterns you’ve already mastered. Your Hello World experience provides the conceptual foundation that makes these advanced tools approachable rather than overwhelming.


6 Key Takeaways

  1. Remix IDE eliminates setup complexity, enabling smart contract deployment within 15 minutes using only a web browser
  2. Sepolia and other testnets provide a risk free environment for learning blockchain development with free test Ether from faucets
  3. Hello World contracts teach fundamental Solidity concepts including state variables, function visibility, and constructor initialization
  4. MetaMask integration bridges web browsers and blockchain networks, enabling seamless contract interaction through familiar interfaces
  5. Block explorers provide transparency and verification for deployed contracts, allowing anyone to audit on chain activity
  6. Your successful Hello World deployment provides the foundation for building sophisticated decentralized applications across multiple blockchain platforms

Get The Blockchain Sector Newsletter, binge the YouTube channel and connect with me on Twitter

The Blockchain Sector newsletter goes out a few times a month when there is breaking news or interesting developments to discuss. All the content I produce is free, if you’d like to help please share this content on social media.

Thank you.

James Bachini

Disclaimer: Not a financial advisor, not financial advice. The content I create is to document my journey and for educational and entertainment purposes only. It is not under any circumstances investment advice. I am not an investment or trading professional and am learning myself while still making plenty of mistakes along the way. Any code published is experimental and not production ready to be used for financial transactions. Do your own research and do not play with funds you do not want to lose.


Posted

in

, , , ,

by