Skip to main content
Solidity Code Reorder Medium +20 XP

ERC-20 Transfer

Arrange the ERC-20 transfer logic correctly.

Click lines in the correct order

Available lines4 left

Your order

Click lines above to build your solution.

Show answer and explanation

Answer: require(balances[msg.sender] >= amount); balances[msg.sender] -= amount; balances[to] += amount; emit Transfer(msg.sender, to, amount);

Check balance, deduct from sender, credit recipient, then emit event. Check first to catch errors early.

Hint: Check, then update sender, update recipient, then emit.

What this challenge tests

Code Reorder in Solidity: erc20, transfer.

Related challenges