0
0
Blockchain / Solidityprogramming~20 mins

Why dApps need user interfaces in Blockchain / Solidity - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
dApp UI Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why do decentralized applications (dApps) require user interfaces?

Choose the best reason why dApps need user interfaces for users.

ATo store user data directly on the interface instead of the blockchain
BTo allow users to interact easily with blockchain functions without coding knowledge
CBecause blockchain networks cannot run without a graphical interface
DBecause smart contracts require a user interface to execute transactions
Attempts:
2 left
💡 Hint

Think about how normal people use apps and what they need to do with dApps.

Predict Output
intermediate
2:00remaining
What does this simple dApp UI code output?

Given this JavaScript snippet simulating a dApp UI interaction, what is the console output?

Blockchain / Solidity
async function connectWallet() {
  const walletConnected = true;
  if (walletConnected) {
    return 'Wallet connected';
  } else {
    return 'Please connect your wallet';
  }
}

connectWallet().then(console.log);
Aundefined
BPlease connect your wallet
CError: walletConnected is not defined
DWallet connected
Attempts:
2 left
💡 Hint

Look at the value of walletConnected and what the function returns.

🔧 Debug
advanced
3:00remaining
Why does this dApp UI code fail to update the balance display?

Identify the bug in this React code snippet that prevents the balance from showing after fetching.

Blockchain / Solidity
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';
}
AThe code tries to assign to 'balance' directly instead of using setBalance
BThe useEffect hook is missing a dependency array
CThe getBalanceFromBlockchain function is not awaited properly
DThe initial state of balance should be 0, not null
Attempts:
2 left
💡 Hint

Remember how React state variables are updated.

📝 Syntax
advanced
2:00remaining
Which option fixes the syntax error in this dApp UI code snippet?

Fix the syntax error in this JavaScript object used for UI state:

const state = { connected: true, balance: '5 ETH', }
ARemove the trailing comma after 'balance: "5 ETH"'
BChange the quotes around '5 ETH' to single quotes
CAdd a semicolon after the closing brace
DAdd a key 'wallet' with value null
Attempts:
2 left
💡 Hint

Trailing commas in object literals can cause errors in some JavaScript environments.

🚀 Application
expert
3:00remaining
How many user interface components are needed to fully interact with a dApp wallet?

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?

A2 components: WalletInterface, TransactionPanel
B3 components: WalletConnector, TokenSender, HistoryViewer
C4 components: ConnectButton, BalanceDisplay, SendForm, TransactionList
D5 components: ConnectButton, BalanceDisplay, SendForm, TransactionList, SettingsPanel
Attempts:
2 left
💡 Hint

Think about each unique user action or view needed.