How to Create a “Hello World” Solidity Smart Contract

A “Hello World” Solidity smart contract is the shortest useful program you can put on Ethereum: a few lines that store a greeting on-chain and hand it back when asked. It won’t move money or run a protocol, but it teaches the loop every developer repeats forever — write code, compile it, deploy it, and call it.

This guide builds that first contract from scratch, explains every line, and walks through deploying it to a live test network. No prior blockchain experience is assumed. By the end you’ll understand what the code does, how it reaches the chain, and where to go next.

What Is a Smart Contract?

A smart contract is a program stored on a blockchain that runs exactly as written when its conditions are met. Once it’s deployed, no one — including its author — can quietly change the logic, and anyone on the network can call it.

That permanence is the real difference from a normal app. A web server can be edited or switched off by whoever owns it; a deployed contract keeps running on thousands of machines with no off switch. That’s a strength for trust and a hazard for bugs, which is why testing matters so much.

The term is older than Ethereum by two decades. Computer scientist and legal scholar Nick Szabo defined it in his 1996 paper Smart Contracts: Building Blocks for Digital Free Markets:

“A smart contract is a set of promises, specified in digital form, including protocols within which the parties perform on these promises.” — Nick Szabo, 1996

On Ethereum, those “promises” are code, and the “protocol” is the Ethereum Virtual Machine (EVM) — the runtime that executes contract code identically on every node in the network.

Why start with “Hello World”?

Because it separates the workflow from the logic. Ethereum’s ecosystem is deep and full of moving parts, so a beginner needs one thing that works end to end before adding complexity.

Print a greeting, deploy it, read it back. The mechanics you learn on this tiny example are the same ones behind a token, an NFT collection, or a lending market — only the logic in the middle grows.

What Is Solidity, and Why Does Ethereum Use It?

Solidity is the main language for writing smart contracts on Ethereum and other EVM-compatible chains. It’s statically typed and looks a lot like JavaScript with stricter rules, which was a deliberate choice to make it approachable for web developers.

Solidity was proposed in 2014 and is maintained by a dedicated team under the Ethereum Foundation. It still moves quickly: the latest stable release is 0.8.37, published on September 10, 2026. Your code compiles down to EVM bytecode, and the EVM works in 256-bit words — that’s why you’ll see types like uint256 all over Solidity code.

Here’s why the language matters for a beginner. Solidity hides raw bytecode behind readable syntax, so you write logic instead of stack operations. That readability is also a safety feature, because a bug on a public chain is expensive and permanent, and code you can actually read is code you can actually audit.

Who Uses Solidity in Practice?

Almost anyone building on Ethereum touches it eventually. The same first contract you’re about to write scales up to systems securing billions of dollars in on-chain value.

Common authors and their use cases include:

  • DeFi developers building exchanges, lending markets, and stablecoins.
  • NFT and gaming teams minting tokens with the ERC-721 and ERC-1155 standards.
  • DAO builders encoding voting and treasury rules that execute without a middleman.
  • Enterprises piloting supply-chain tracking, settlement, and tokenized assets.
  • Auditors and learners who need to read contracts fluently before they can secure them.

So “Hello World” isn’t a toy detour. It’s the on-ramp every one of these people started on.

What You Need Before You Start

You can write and deploy your first contract entirely in a browser, with nothing installed locally. The short list:

  • Remix IDE — a free, browser-based editor at remix.ethereum.org that compiles and deploys with zero setup.
  • A browser wallet such as MetaMask, needed only when you deploy to a public test network.
  • Test ETH — free tokens for paying gas on a testnet, claimed from a faucet.
  • Basic programming familiarity — helpful but optional; this example is small enough to follow cold.

No node to install, no command line, no real money. That’s the whole point of starting here.

Writing Your First Contract in Remix

Open Remix, create a file called HelloWorld.sol, and paste in the contract below. One line of real state does all the work.

solidity

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

contract HelloWorld {
    string public greet = "Hello, World!";
}

Breaking down the code

Each line has a job, and skipping any of them will trip the compiler or a warning.

  1. // SPDX-License-Identifier: MIT declares the software license. The compiler warns when it’s missing, so treat it as a required first line.
  2. pragma solidity ^0.8.0; sets which compiler versions are allowed. The caret ^ means “0.8.0 or any compatible 0.8.x release,” so it builds with 0.8.37 but rejects a breaking 0.9.0.
  3. contract HelloWorld { ... } declares the contract itself, much like a class in other languages.
  4. string public greet = "Hello, World!"; creates a state variable stored permanently on-chain. The public keyword tells Solidity to generate a free getter function automatically, so anyone can read greet without you writing extra code.

That’s the smallest complete Solidity smart contract that does something visible. You didn’t write a single function, yet the contract already exposes readable data.

Making the Contract Interactive

Reading a fixed string is a start, but the interesting part of any Solidity smart contract is changing state. Add one function so the greeting can be updated after deployment:

solidity

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

contract HelloWorld {
    string public greet = "Hello, World!";

    function setGreeting(string memory _newGreeting) public {
        greet = _newGreeting;
    }
}

This introduces the single most important distinction in Ethereum development: reading versus writing.

  • Reading greet is free. It’s a view of existing data and needs no transaction.
  • Calling setGreeting changes on-chain state, so it costs gas and requires a wallet-signed transaction that the whole network processes.

The word memory in the parameter tells Solidity where to hold _newGreeting during the call — in temporary memory rather than permanent storage. Getting data location right is one of the first real skills a Solidity developer builds.

How to Compile and Deploy to a Test Network

Deployment is where the contract stops being text and becomes a live address on a blockchain. Work through these steps in order.

  1. Compile. In Remix’s Solidity Compiler tab, pick a 0.8.x version and click Compile HelloWorld.sol. Compilation turns your code into EVM bytecode; a green checkmark means it’s valid.
  2. Test locally first. In the Deploy & Run Transactions tab, choose the “Remix VM” environment — a simulated chain inside your browser. Deploy here to confirm the contract works at zero cost and zero risk.
  3. Connect a wallet. Switch the environment to “Injected Provider” to link MetaMask, then point your wallet at a test network.
  4. Choose the right testnet. Use Sepolia (chain ID 11155111), which Ethereum’s own documentation calls the recommended default testnet for application development. Skip Holesky — it was deprecated in September 2025 — and note that Hoodi exists for validator testing, not contract work.
  5. Get test ETH. Claim free Sepolia ETH from a faucet to cover gas. Our guide to the Sepolia testnet covers current faucets and how the network fits a testing workflow.
  6. Deploy and confirm. Click Deploy, approve the transaction in your wallet, and wait for it to be mined. Your contract now has a permanent address you can open in a block explorer.

Once it’s live, expand the contract under Deployed Contracts and click the blue greet button. It returns “Hello, World!” — read straight off the blockchain.

One timing caveat worth knowing: Sepolia is late in its lifecycle, with an estimated end-of-life around September 30, 2026 and a successor testnet planned to run alongside it during a migration window. Always check a testnet’s current status before you commit a long project to it.

Remix vs. Hardhat vs. Foundry: Which Tool Should You Use?

Remix is ideal for a first contract, but most teams eventually move to a local framework for testing and automation. The three dominant options in 2026 line up like this:

ToolBest forInterfaceLearning curve
RemixFirst contracts, quick experiments, teachingBrowser IDELowest
HardhatJavaScript/TypeScript teams, large plugin ecosystemJS/TS CLIModerate
FoundryFast testing and Solidity-native workflowsSolidity/Rust CLISteeper

The practical rule: start in Remix, then adopt Hardhat if your team lives in JavaScript, or Foundry if you’d rather write tests in Solidity itself and care about speed.

When you deploy from Hardhat or Foundry to a public testnet or mainnet, the framework needs a connection to Ethereum to broadcast the transaction. Rather than running and syncing your own machine, many developers point the framework at a hosted Ethereum endpoint and keep their attention on the contract. NOWNodes offers that access across 120+ networks, and its free public endpoints are enough for early testing. For the command-line version of this workflow, see the walkthrough on deploying a smart contract on Ethereum.

Common Mistakes and Limits to Know

A first contract is forgiving. A production one is not, so it helps to learn the guardrails early.

  • Contracts have a size cap. EIP-170 limits deployed bytecode to 24 KB (24,576 bytes), so large contracts must be split or optimized.
  • Deployed code is immutable. You can’t edit a live contract. Fixing a bug means deploying a new version and migrating users — the reason testnets exist.
  • Gas isn’t free on mainnet. Every operation costs gas paid in ETH, and storage is especially expensive, so on-chain data gets used sparingly.
  • Avoid a floating pragma in production. ^0.8.0 is fine for learning, but shipped contracts usually pin one exact version so builds are reproducible.
  • Never expose a private key. Learn on a testnet with a throwaway wallet, and treat mainnet keys like cash.

Conclusion

You now have the full loop: a Solidity smart contract written, made interactive, compiled, deployed to a test network, and called to return its greeting. That sequence — write, compile, deploy, interact — doesn’t change as the contracts get harder; only the logic in the middle does.

The natural next steps are functions that take input and enforce rules, then a move from Remix to Hardhat or Foundry once the basics feel routine. Keep everything on Sepolia until your code is solid, and only then think about mainnet. If you want the wider picture of how contracts fit alongside wallets, front ends, and data, the developer’s guide to the Web3 stack is a good map.

FAQ

Is Solidity hard to learn for beginners?

Not for the basics. If you’ve written any JavaScript, Python, or Java, the syntax will feel familiar, and a contract like this one takes minutes. The genuinely hard parts are security and gas optimization, and those come with practice.

How much does it cost to deploy a smart contract?

On a testnet, nothing — test ETH is free from faucets. On Ethereum mainnet you pay gas in real ETH, and the amount depends on network congestion and contract size, so most teams estimate it before deploying.

Can a deployed smart contract be changed or deleted?

Not directly. A contract’s deployed code is immutable. Teams work around this with upgradeable proxy patterns that route calls to a replaceable logic contract, but the underlying deployed bytecode itself never changes.

What’s the difference between Solidity and Vyper?

Both compile to EVM bytecode, but Solidity is the most widely used language with the largest ecosystem and tooling, while Vyper is a smaller, Python-like alternative that trades features for simplicity and auditability. Beginners almost always start with Solidity.

Do I need ETH just to write a contract?

No. Writing and compiling in Remix costs nothing, and the local Remix VM lets you deploy for free. You only need ETH — test or real — when you deploy to an actual network.