Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

OpenZeppelinのERC20Burnableの目的

こんにちはJPです。(https://twitter.com/salvacion_jp)

トピックはERC20Burnableについてです。This article tackles how tokens are issued and burned.

OpenZeppelin

This is a library for secure smart contract development.

ERC20Burnableとは

これは不可逆的に焼けたされた可能性のあるトークンです。

Source: token/ERC20/ERC20Burnable.sol

ERC20BurnableのFunction

_burn

Overrides ERC20._burn in order for burn and burnFrom to emit an additional Burn event.

引数:
who - address
value - uint256

function _burn(address who, uint256 value) internal

burn

Burns a specific amount of tokens.

引数:
value - The amount of token to be burned.

function burn(uint256 value) public

burnFrom

Burns a specific amount of tokens from the target address and decrements allowance.

引数:
from - address The address which you want to send tokens from
value - uint256 The amount of token to be burned

function burnFrom(address from, uint256 value) public

ERC20Burnableの必要性

Scalability and Security

トークンの作成中に、トークンの初期供給が定義される。 すべては当初契約作成者に属します。Function は、契約作成者だけが呼び出し可能で、呼び出されるとさらに多くのトークンを発行します。

これからの新しいトークンは、まず契約作成者になります。

Issue and Burn

function issueTokens(uint256 _extraTokens) public{
// Make sure only the contract creator can call this
require(msg.sender == creator);
balances[msg.sender] = balances[msg.sender].add(_extraTokens);
//We have to emit an event for each token that gets created
for(uint i = maxId.add(1); i <= maxId.add(_extraTokens); i++){
emit Transfer(0x0, creator, i);
}
maxId += _extraTokens; //<- SafeMath for this operation
// was done in for loop above
}

As per the article, in both the cases of addition add function from SafeMath was used so that it would not result to a huge value of _extraTokens.

function burnToken(uint256 _tokenId) external{
address owner = ownerOf(_tokenId);
require ( owner == msg.sender
|| allowance[_tokenId] == msg.sender
|| authorised[owner][msg.sender]
);
burned[_tokenId] = true;
balances[owner]--;
emit Transfer(owner, 0x0, _tokenId);
}

Summary

ERC 721のトークンは、より具体的なものを表します。トークンホルダーがより多くのトークンを作成できるようにしたくない場合、functionを使います。

ありがとうございました。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
0
Help us understand the problem. What are the problem?