Home/Blockchain/Deploy Your First Contract/Interaction Verification

๐Ÿ” Call Functions & Verify Results

Interact with your deployed contract and confirm transactions on-chain

โ†
Previous
Compilation & Deployment

๐Ÿ”— Interaction & Verification

Your contract is deployed! Now let's interact with itโ€”read data, write data, and verify the source code on Etherscan.

๐ŸŽฎ Interactive: Contract Interaction Simulator

Choose an action to see how to interact with your deployed contract

๐Ÿ“–
Read Data (Free)
Call storedData() to read the current value
Gas Cost: FREE
Steps to Read Data (Free):
1
Click on "storedData" button in Remix
2
Function executes locally (no transaction)
3
View returns current value instantly
4
No gas cost, no waiting
Code Example:
// Read value (free call)
const value = await contract.storedData()
console.log(value) // Current stored number

๐Ÿ“– Read vs โœ๏ธ Write Operations

๐Ÿ“–
Read Operations (Calls)
โœ… FREE - No gas cost
โœ… Instant - No waiting
โœ… No Transaction - Executes locally
โœ… View Functions - Only read state
contract.storedData() // FREE
โœ๏ธ
Write Operations (Transactions)
โš ๏ธ Costs Gas - Pay for computation
โณ Wait ~15s - Block confirmation
๐Ÿ“ Creates Transaction - Broadcasted to network
๐Ÿ”„ Modifies State - Changes blockchain
contract.set(42) // ~25K gas

๐Ÿ” Using Etherscan to Interact

Etherscan provides a user-friendly interface to interact with any contractโ€”no code required!

Step 1: Find Your Contract

Go to sepolia.etherscan.io and paste your contract address

Step 2: Navigate to "Read Contract"

Click the "Contract" tab โ†’ "Read Contract" to view all view functions

Step 3: Call storedData()

Click "storedData" to see current value. No wallet connection needed!

Step 4: Navigate to "Write Contract"

Click "Write Contract" โ†’ Connect MetaMask when prompted

Step 5: Call set()

Enter value โ†’ Click "Write" โ†’ Confirm in MetaMask โ†’ Wait for confirmation

โœ… Why Verify Your Contract?

๐Ÿ”“
Transparency

Anyone can read source code and verify what the contract does

๐Ÿ›ก๏ธ
Trust

Users can audit logic and confirm no hidden malicious code

๐Ÿงฐ
Better UX

Etherscan shows function names instead of raw bytecode

๐Ÿ“Š
Analytics

Track contract usage, events, and transactions easily

๐Ÿ”— Interacting with Web3.js

For dApp developers, here's how to interact programmatically:

import { ethers } from 'ethers'

// Connect to wallet
const provider = new ethers.BrowserProvider(window.ethereum)
const signer = await provider.getSigner()

// Contract instance
const contract = new ethers.Contract(
  '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb', // Address
  ['function set(uint256 x)', 'function storedData() view returns (uint256)'], // ABI
  signer
)

// Read value (free)
const value = await contract.storedData()
console.log('Stored value:', value)

// Write value (costs gas)
const tx = await contract.set(123)
await tx.wait() // Wait for confirmation
console.log('New value set to 123!')

โš ๏ธ Common Pitfalls

โŒ
Calling Write Functions Without Gas
Always ensure wallet has testnet ETH before calling state-changing functions!
โŒ
Not Waiting for Confirmation
Always use await tx.wait() to ensure transaction is mined
โŒ
Wrong Network
Double-check MetaMask is on correct network (Sepolia for testnet)
โŒ
Incorrect ABI
Use exact ABI from compilation outputโ€”function signatures must match!

๐ŸŽฏ Next Steps

1๏ธโƒฃ
Try Different Values: Set 999, 0, 123456 and read them back
2๏ธโƒฃ
Check Transactions: View all transactions on Etherscan
3๏ธโƒฃ
Share Address: Let friends interact with YOUR contract!
4๏ธโƒฃ
Build a dApp: Create a web interface with Web3.js/Ethers.js