0
0
Blockchain / Solidityprogramming~30 mins

First smart contract deployment in Blockchain / Solidity - Mini Project: Build & Apply

Choose your learning style9 modes available
First smart contract deployment
📖 Scenario: You want to create a simple smart contract on the Ethereum blockchain that stores a number and allows you to update it.
🎯 Goal: Build and deploy a basic smart contract that stores a number and lets you change it.
📋 What You'll Learn
Create a smart contract named SimpleStorage
Add a state variable storedNumber of type uint
Write a function setNumber that updates storedNumber
Write a function getNumber that returns storedNumber
Deploy the contract and call getNumber to see the stored value
💡 Why This Matters
🌍 Real World
Smart contracts are programs that run on blockchains to automate agreements and store data securely.
💼 Career
Understanding how to write and deploy smart contracts is essential for blockchain developers and jobs in decentralized finance (DeFi) and NFTs.
Progress0 / 4 steps
1
Create the smart contract and state variable
Write a Solidity contract named SimpleStorage with a public state variable storedNumber of type uint initialized to 0.
Blockchain / Solidity
Need a hint?

Start by declaring the contract and a public unsigned integer variable initialized to zero.

2
Add a function to update the stored number
Inside the SimpleStorage contract, add a public function named setNumber that takes a uint parameter called newNumber and sets storedNumber to newNumber.
Blockchain / Solidity
Need a hint?

Write a function that takes a number and updates the storedNumber variable.

3
Add a function to read the stored number
Inside the SimpleStorage contract, add a public view function named getNumber that returns a uint and returns the value of storedNumber.
Blockchain / Solidity
Need a hint?

Create a function that returns the current stored number without changing state.

4
Deploy and test the contract
Deploy the SimpleStorage contract on a test network or local blockchain. Then call setNumber(42) and afterwards call getNumber() to print the stored number.
Blockchain / Solidity
Need a hint?

Use Remix IDE or a local blockchain like Hardhat to deploy and test your contract. Call setNumber(42) then getNumber() to see 42.