Small token
Combine state, events and functions into a minimal token.
What you will be able to do
- Map balances.
- Emit a transfer event.
- Check balances before transfer.
In plain English
Combine state, events and functions into a minimal token.
- Map balances.
- Emit a transfer event.
- Check balances before transfer.
pragma solidity ^0.8.24;
contract Token {
mapping(address => uint256) public balanceOf;
event Transfer(address indexed from, address indexed to, uint256 value);
function transfer(address to, uint256 value) external {
require(balanceOf[msg.sender] >= value, "balance");
balanceOf[msg.sender] -= value;
balanceOf[to] += value;
emit Transfer(msg.sender, to, value);
}
}Your turn
EasyExplain it back
Answer from memory: Which structure maps addresses to balances?
TEXT · starter
Your answer…Check your understanding before moving on.
Knowledge checkQuestion 1
Which structure maps addresses to balances?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.