Choose the best reason why dApps need user interfaces for users.
Think about how normal people use apps and what they need to do with dApps.
dApps run on blockchains but users need simple ways to send transactions and see results. User interfaces make this easy without coding.
Given this JavaScript snippet simulating a dApp UI interaction, what is the console output?
async function connectWallet() { const walletConnected = true; if (walletConnected) { return 'Wallet connected'; } else { return 'Please connect your wallet'; } } connectWallet().then(console.log);
Look at the value of walletConnected and what the function returns.
The variable walletConnected is true, so the function returns 'Wallet connected'.
Identify the bug in this React code snippet that prevents the balance from showing after fetching.
import React, { useState, useEffect } from 'react'; function Balance() { const [balance, setBalance] = useState(null); useEffect(() => { async function fetchBalance() { const bal = await getBalanceFromBlockchain(); setBalance(bal); } fetchBalance(); }, []); return <div>Your balance: {balance}</div>; } async function getBalanceFromBlockchain() { return '10 ETH'; }
Remember how React state variables are updated.
React state variables must be updated using their setter function. Direct assignment to 'balance' does not update the UI.
Fix the syntax error in this JavaScript object used for UI state:
const state = { connected: true, balance: '5 ETH', }Trailing commas in object literals can cause errors in some JavaScript environments.
Trailing commas after the last property in an object literal can cause syntax errors in older JavaScript versions or strict modes.
Consider a dApp wallet interface that allows users to connect, view balance, send tokens, and view transaction history. How many distinct UI components are minimally required?
Think about each unique user action or view needed.
Each main function (connect, view balance, send tokens, view history) requires a separate UI component for clarity and usability.