This is a simple Web3 application that allows users to interact with a deployed smart contract on the Ethereum Sepolia testnet. The contract stores a message string which can be retrieved or updated by connected users using MetaMask.
- Connect MetaMask wallet
- Read current message from the smart contract
- Update the message (on-chain transaction)
- Solidity (Smart contract)
- Ethers.js (Frontend interaction)
- MetaMask (Wallet connection)
- Remix (Contract Deployment)
- VS Code (Frontend development)
- Open
index.htmlin a web browser (preferably Chrome with MetaMask installed). - Click “Connect Wallet” to link your MetaMask.
- Click “Get Message” to read the current value stored on-chain.
- Enter a new message and click “Update Message” to send a transaction.
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.2 <0.9.0;
contract HelloWeb3 {
string public message;
constructor(string memory _message) {
message = _message;
}
function setMessage(string memory _newMessage) public {
message = _newMessage;
}
function getMessage() public view returns (string memory) {
return message;
}
}