1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

こんにちは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を使います。

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

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?