0
0
Blockchain / Solidityprogramming~20 mins

Blockchain use cases beyond crypto - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Blockchain Use Cases Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this smart contract function?

Consider a smart contract function that stores and retrieves a document hash for supply chain tracking. What will be the output after calling getDocumentHash()?

Blockchain / Solidity
contract SupplyChain {
    string private documentHash;

    function storeDocumentHash(string memory hash) public {
        documentHash = hash;
    }

    function getDocumentHash() public view returns (string memory) {
        return documentHash;
    }
}

// After calling storeDocumentHash("abc123hash")
// What does getDocumentHash() return?
A"abc123hash"
B"documentHash"
C""
Dnull
Attempts:
2 left
💡 Hint

Think about what value is stored and returned by the function.

🧠 Conceptual
intermediate
1:30remaining
Which blockchain feature best supports secure medical record sharing?

In healthcare, sharing patient records securely is critical. Which blockchain feature helps ensure data integrity and controlled access?

AProof of Work mining
BAnonymous public transactions
CImmutable ledger with permissioned access
DUnlimited data storage on-chain
Attempts:
2 left
💡 Hint

Consider how data can be protected and shared only with authorized parties.

🔧 Debug
advanced
2:30remaining
Why does this blockchain voting contract fail to count votes correctly?

Review the following simplified voting contract code. Why does the vote count remain zero after voting?

Blockchain / Solidity
contract Voting {
    mapping(address => bool) public voters;
    uint public voteCount;

    function vote() public {
        if (!voters[msg.sender]) {
            voters[msg.sender] = true;
            voteCount = voteCount + 1;
        }
    }

    function getVotes() public view returns (uint) {
        return voteCount;
    }
}

// After calling vote() from different addresses, voteCount is still 0.
AThe contract is deployed but vote() is never called successfully due to missing payable modifier
BThe voteCount variable is private and cannot be read
CThe mapping voters is not initialized, causing voteCount to reset
DThe voteCount variable is not updated because vote() is never executed in a transaction
Attempts:
2 left
💡 Hint

Think about how blockchain state changes happen and what is needed to update state variables.

📝 Syntax
advanced
1:30remaining
Which option fixes the syntax error in this blockchain identity contract snippet?

Identify the correct fix for the syntax error in this Solidity code snippet:

mapping(address => string) public identities

function setIdentity(string memory name) public {
    identities[msg.sender] = name;
}
AAdd a semicolon after the mapping declaration
BAdd <code>public</code> keyword to the function setIdentity
CChange <code>string</code> to <code>string memory</code> in mapping
DReplace <code>msg.sender</code> with <code>address(this)</code>
Attempts:
2 left
💡 Hint

Check the end of the mapping declaration line.

🚀 Application
expert
3:00remaining
How many unique assets are tracked after these blockchain transactions?

A blockchain asset tracking contract stores assets by unique IDs. After these transactions, how many unique assets are stored?

storeAsset(101, "Car")
storeAsset(102, "Bike")
storeAsset(101, "Truck")
storeAsset(103, "Boat")
storeAsset(102, "Scooter")
A2
B3
C5
D4
Attempts:
2 left
💡 Hint

Consider that storing an asset with an existing ID overwrites the previous one.