Smart Contract Puzzle

Interactive smart contract simulator and Solidity learning tool

How to Learn Smart Contracts:

  1. Select a Contract: Choose from Counter, Token, Voting, or Auction
  2. Read the Code: Study the Solidity contract structure
  3. View State: See current contract state variables
  4. Execute Functions: Call functions with different parameters
  5. Track Changes: Watch state update as functions execute
  6. Monitor Gas: See cumulative gas costs for operations

📋 Select a Smart Contract

📜 Execution History

🧠 Understanding Smart Contracts

Smart contracts are self-executing programs that run on the blockchain. They automatically execute when conditions are met, with no intermediary needed. In this tool, you'll learn how contracts store state, execute functions, and consume gas.

💾 State Variables

Data stored permanently on-chain. Changing state costs gas and requires a transaction.

⚙️ Functions

CODE that executes when called. Some change state (cost gas), others just read (view functions).

🔐 Visibility

Public functions can be called by anyone. Private functions only work internally.

💨 Gas Cost

Every operation costs gas. More complex operations = higher cost. Total gas = operations × gas price.

📚 Contract Types in This Tool

1. Counter Contract

The simplest contract! Tracks a number and lets you increment/decrement it. Perfect for learning basics.

2. Token Contract

Simulates ERC20 token transfers. Teaches how token balances work across addresses.

3. Voting Contract

Democratic decision-making on blockchain. Shows struct usage and voting logic.

4. Auction Contract

Competitive bidding system. Shows require statements and value validation.

⛽ Understanding Gas

Gas measures computational cost. Every EVM operation costs gas. The simulator shows approximate gas for each function:

💡 Real Cost: Gas Cost (wei) = Total Gas × Gas Price (gwei)

🔍 Function Types

In this tool, VIEW functions show with blue background | STATE functions show with green background.