민팅과 소각
공급량 관리
민팅과 소각은(는) CoddyKit의 무료 Web3 & DApp Development Fundamentals 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Web3 & DApp Development Fundamentals 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Web3 & DApp Development Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Managing Supply
Minting creates new tokens and burning destroys them. Together they let a token's totalSupply grow or shrink over time.
These operations are not part of the core ERC-20 interface, but they are extremely common extensions.
What Minting Does
Minting increases totalSupply and credits new tokens to a recipient's balance. It is how tokens enter circulation - at deployment, as rewards, or on demand.
Implementing Mint
A mint function adds to both totalSupply and the recipient's balance, then emits a Transfer event from the zero address.
<code>function _mint(address to, uint256 amount) internal {
require(to != address(0), 'mint to zero');
totalSupply += amount;
balanceOf[to] += amount;
emit Transfer(address(0), to, amount);
}</code>Mint Emits From Zero
By convention a mint is logged as a Transfer from address(0). Wallets and indexers interpret a transfer originating at the zero address as new tokens being created.
<code>emit Transfer(address(0), to, amount); // signals minting</code>What Burning Does
Burning reduces totalSupply and subtracts from a holder's balance, permanently removing tokens from circulation. It is used for deflationary mechanics, redemptions, and buybacks.
Implementing Burn
A burn function checks the holder's balance, decreases it and totalSupply, then emits a Transfer to the zero address.
<code>function _burn(address from, uint256 amount) internal {
require(balanceOf[from] >= amount, 'burn exceeds balance');
balanceOf[from] -= amount;
totalSupply -= amount;
emit Transfer(from, address(0), amount);
}</code>Burn Emits To Zero
Symmetrically, a burn is logged as a Transfer to address(0). Tokens sent to the zero address are unrecoverable, which is exactly the intent.
<code>emit Transfer(from, address(0), amount); // signals burning</code>Access Control on Mint
Minting must be restricted - an open mint function lets anyone create unlimited tokens, destroying value. Gate it behind an owner or minter role.
<code>address public owner;
modifier onlyOwner() { require(msg.sender == owner, 'not owner'); _; }
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}</code>Burning Your Own Tokens
Holders are usually allowed to burn their own tokens freely. A public burn simply burns from msg.sender.
<code>function burn(uint256 amount) public {
_burn(msg.sender, amount);
}</code>Capped Supply
To guarantee scarcity, a token can enforce a maximum supply by checking against a cap before minting.
<code>uint256 public immutable cap;
function mint(address to, uint256 amount) public onlyOwner {
require(totalSupply + amount <= cap, 'cap exceeded');
_mint(to, amount);
}</code>Burn From Allowance
Like transferFrom, a burnFrom lets an approved spender burn another account's tokens, decrementing the allowance first.
<code>function burnFrom(address from, uint256 amount) public {
require(allowance[from][msg.sender] >= amount, 'allowance');
allowance[from][msg.sender] -= amount;
_burn(from, amount);
}</code>Quick Check
Test your understanding of minting and burning.
Recap
You learned supply management:
- Mint increases totalSupply, credits a balance, emits Transfer from address(0)
- Burn decreases totalSupply, debits a balance, emits Transfer to address(0)
- Minting must be access-controlled; holders can usually burn their own tokens
- Caps enforce a maximum supply; burnFrom uses allowances
자주 묻는 질문
“민팅과 소각” 강의는 무료인가요?
네 — “민팅과 소각” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Web3 & DApp Development Fundamentals 강의 전체를 잠금 해제할 수 있습니다. Web3 & DApp Development Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.
“민팅과 소각”에서 뭘 배우나요?
공급량 관리 브라우저에서 직접 실행하는 실습 코드로 Web3 & DApp Development Fundamentals을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Web3 & DApp Development Fundamentals을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Web3 & DApp Development Fundamentals은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.
“민팅과 소각” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Web3 & DApp Development Fundamentals 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Web3 & DApp Development Fundamentals 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.