What is Ethereum?
Ethereum is a decentralized blockchain platform that enables developers to build and deploy smart contracts and decentralized applications (dApps). It features a virtual machine (EVM) that executes code in a distributed manner across the network.
What is the key difference between Web2 and Web3 development?
Web2 applications rely on centralized servers and databases controlled by companies, while Web3 applications run on decentralized blockchain networks where data and logic are distributed across many nodes, giving users more control and ownership.
What is gas in Ethereum?
Gas is the unit that measures the computational effort required to execute operations on Ethereum. Users pay gas fees (in ETH) to compensate miners/validators for processing their transactions. More complex operations require more gas.
What is the Ethereum Virtual Machine (EVM)?
The EVM is a runtime environment for smart contracts on Ethereum. It's a virtual computer that executes bytecode in a deterministic way across all network nodes, ensuring consistent results regardless of where the code runs.
What is the difference between a testnet and mainnet?
Mainnet is the live Ethereum network where real ETH has value. Testnets (like Sepolia, Goerli) are separate networks that mimic mainnet but use test ETH with no real value, allowing developers to test applications safely and for free.
What is Base blockchain?
Base is a Layer 2 blockchain built on Ethereum using Optimistic Rollup technology. It offers faster transactions and lower fees while maintaining Ethereum's security. It's built by Coinbase to make onchain development more accessible.
What is a smart contract?
A smart contract is a self-executing program stored on the blockchain that automatically runs when predetermined conditions are met. It contains code that defines rules and agreements, eliminating the need for intermediaries.
What is a wallet in the context of blockchain?
A wallet is a tool that stores your private keys and allows you to interact with blockchains. It can send/receive cryptocurrencies, connect to dApps, and sign transactions. Popular wallets include MetaMask, Coinbase Wallet, and WalletConnect.
What is a transaction on Ethereum?
A transaction is a signed message that changes the blockchain state. It can transfer ETH, execute smart contract functions, or deploy new contracts. Transactions are irreversible once confirmed and included in a block.
What makes blockchain applications decentralized?
Blockchain applications are decentralized because they run on a network of many independent nodes rather than a single server. No single entity controls the network, data is distributed across nodes, and consensus mechanisms ensure agreement without central authority.
What is the purpose of private and public keys?
Public keys serve as your blockchain address where others can send you funds. Private keys prove ownership and are used to sign transactions. You must keep private keys secret - anyone with access can control your funds.
Why do transactions sometimes fail on Ethereum?
Transactions can fail due to: insufficient gas limit, running out of gas during execution, revert conditions in smart contracts, network congestion, or incorrect transaction parameters. Failed transactions still consume gas.
What data type should you use to store Ethereum addresses in Solidity?
Use the `address` type to store Ethereum addresses. It's a 20-byte value that can hold account addresses. You can also use `address payable` for addresses that can receive Ether directly.
What is the difference between `uint` and `uint256` in Solidity?
`uint` and `uint256` are exactly the same thing. `uint` is an alias for `uint256`, representing an unsigned 256-bit integer. It's the most commonly used integer type in Solidity and can hold values from 0 to 2^256 - 1.
What does the `payable` keyword do in Solidity functions?
The `payable` keyword allows a function to receive Ether. Without `payable`, a function will reject transactions that try to send Ether to it. Use `msg.value` to access the amount of Ether sent to a payable function.
What's the difference between `view` and `pure` functions in Solidity?
`view` functions can read blockchain state but cannot modify it. `pure` functions cannot read or modify state - they only work with their input parameters. Both don't cost gas when called externally, but `pure` is more restrictive than `view`.
How do you declare a mapping in Solidity?
Use the syntax `mapping(KeyType => ValueType) public variableName;`. For example: `mapping(address => uint256) public balances;` creates a mapping from addresses to uint256 values. Mappings are like hash tables or dictionaries.
What is the purpose of the `require()` statement in Solidity?
`require()` validates conditions and reverts the transaction if the condition is false. It's used for input validation, access control, and checking preconditions. Optionally, you can provide an error message: `require(condition, "Error message");`
What does `msg.sender` represent in Solidity?
`msg.sender` is a global variable that contains the address of the account that called the current function. It's commonly used for access control to verify who is executing a function.
How do you define a constructor in Solidity?
Use the `constructor()` keyword followed by function parameters (if any). The constructor runs only once when the contract is deployed: `constructor(uint _initialValue) { owner = msg.sender; value = _initialValue; }`
What's the difference between `memory` and `storage` in Solidity?
`storage` refers to permanent blockchain storage (expensive). `memory` is temporary storage that exists only during function execution (cheaper). Use `memory` for temporary variables and `storage` for state variables that persist between transactions.
How do you emit an event in Solidity?
First declare the event: `event Transfer(address indexed from, address indexed to, uint256 value);` Then emit it: `emit Transfer(msg.sender, recipient, amount);` Events are logged on the blockchain and can be listened to by frontend applications.
What are modifiers in Solidity and how do you use them?
Modifiers are reusable code that can modify function behavior. They're often used for access control or validation. Example: `modifier onlyOwner() { require(msg.sender == owner, "Not owner"); _; }` Use with: `function withdraw() public onlyOwner { ... }`
What does `block.timestamp` provide in Solidity?
`block.timestamp` returns the Unix timestamp of the current block. It's useful for time-based logic, but be aware that miners can manipulate it slightly (±15 seconds). For precise timing, consider using block numbers instead.