「ERC20」の版間の差分

提供: tezos-wiki
移動先: 案内検索
(1版 をインポートしました)
 
1行目: 1行目:
{{#seo:
+
{{#o:
|title= ERC20. All about cryptocurrency - Bitcoin Wiki
+
|タイトル= ERC20。 cryptocurrencyに関するすべて - Bitcoin Wiki
|keywords=blockchain projects, erc20, irc 20 token, token, ethereum token standard
+
| keywords =ブロックチェーンプロジェクト、erc20、irc 20トークン、トークン、ethereumトークン標準
|description=ERC20 is used for Ethereum smart contracts. Developed in 2015, ERC-20 defines a common list of rules that an Ethereum token has to implement. Giving developers the ability to program how new tokens will function within the Ethereum ecosystem.
+
| description = ERC20は、Ethereumスマートコントラクトに使用されます。 2015年に開発されたERC-20では、Ethereumトークンが実装しなければならないルールの共通リストが定義されています。開発者に、新しいトークンがEthereumエコシステム内でどのように機能するかをプログラムする能力を与える。
 
}}
 
}}
  
The [[Ethereum]] token standard ('''ERC20''') is used for Ethereum [[Smart_contract|smart contracts]]. Developed in 2015, '''ERC-20''' defines a common list of rules that an Ethereum token has to implement. Giving developers the ability to program how new tokens will function within the Ethereum ecosystem. This token protocol became popular with crowdfunding companies via [[Initial_coin_offering|Initial Coin Offering]] (ICO).
+
Ethereum [スマートコントラクト|スマートコントラクト]には[[Ethereum]]トークン標準( '' 'ERC20' '')が使用されています。 2015年に開発されたERC-20は、Ethereumトークンが実装しなければならないルールの共通リストを定義しています。開発者に、新しいトークンがEthereumエコシステム内でどのように機能するかをプログラムする能力を与える。このトークンプロトコルは、[[Initial_coin_offering | Initial Coin Offering]](ICO)を通じてクラウドファンディング企業に人気がありました。
  
Mercury Protocol's Global Messaging Token is an example of an application based on ERC20 tokens.
+
Mercury Protocolのグローバル・メッセージング・トークンは、ERC20トークンに基づくアプリケーションの例です。
  
The [https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md ERC20] token standard describes the functions and events that an Ethereum token contract has to implement.
+
[https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md ERC20]トークン標準は、Ethereumトークン契約が実装しなければならない機能とイベントを記述します。
  
==The ERC20 Token Standard Interface==
+
== ERC20トークン標準インタフェース==
Following is an interface contract declaring the required functions and events to meet the ERC20 standard:
+
以下は、ERC20規格を満たすために必要な機能とイベントを宣言するインタフェース契約です。
  
<syntaxhighlight lang="javascript" line='line'>
+
<syntaxhighlight lang = "javascript" line = 'line'>
// ----------------------------------------------------------------------------
+
// ------------------------------------------------ ----------------------------
// ERC Token Standard #20 Interface
+
// ERCトークン標準#20インタフェース
 
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
 
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// ----------------------------------------------------------------------------
+
// ------------------------------------------------ ----------------------------
contract ERC20Interface {
+
契約ERC20Interface {
    function totalSupply() public constant returns (uint);
+
    function totalSupply()public定数が返す値(uint)です。
    function balanceOf(address tokenOwner) public constant returns (uint balance);
+
    function balanceOf(address tokenOwner)public定数が返されます(uintバランス)。
    function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
+
    function allowance(アドレスtokenOwner、address spender)public定数は(uintの残りの部分)を返します。
    function transfer(address to, uint tokens) public returns (bool success);
+
    関数呼び出し(アドレスto、uintトークン)public return(bool success);
    function approve(address spender, uint tokens) public returns (bool success);
+
    機能は承認されます(払い戻し、uintトークン)public return(bool success);
    function transferFrom(address from, address to, uint tokens) public returns (bool success);
+
    function transferFrom(アドレス、アドレス、uintトークンからのアドレス)public returns(bool success);
  
    event Transfer(address indexed from, address indexed to, uint tokens);
+
    イベント転送(uintトークンにインデックス付けされたアドレス、uintトークンにインデックス付けされたアドレス)。
    event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
+
    イベント承認(アドレス指定されたtokenOwner、住所付き出費、uintトークン)。
 
}
 
}
</syntaxhighlight>
+
</ syntaxhighlight>
  
Most of the major tokens on the Ethereum blockchain are ERC20-compliant. The [[GNT]] [[Golem Network Token]] is only partially-ERC20-compliant as it does not implement the <code>approve(...)</code>, <code>allowance(..)</code> and <code>transferFrom(...)</code> functions, and the <code>Approval(...)</code> event.
+
Ethereumブロックチェーンの主要なトークンのほとんどはERC20に準拠しています。 <code> allowance(..</ code><code> allowance(..</ code>を実装していないため、[[GNT]] [[Golem Network Token]]は、 code>および<code> transferFrom(...</ code>関数、および<code> Approval(...</ code>イベントを生成します。
  
Some of the tokens include further information describing the token contract:
+
トークンの一部には、トークン契約を説明する追加情報が含まれています。
  
<syntaxhighlight lang="javascript" line='line'>
+
<syntaxhighlight lang = "javascript" line = 'line'>
    string public constant name = "Token Name";
+
    文字列public constant name = "トークン名";
    string public constant symbol = "SYM";
+
    文字列public constant symbol = "SYM";
    uint8 public constant decimals = 18; // 18 is the most common number of decimal places
+
    uint8 public定数decimals = 18; // 18は最も一般的な小数点以下の桁数です
</syntaxhighlight>
+
</ syntaxhighlight>
  
 
<br />
 
<br />
  
==How Does A Token Contract Work?==
+
==トークン契約はどのように機能するのですか?==
  
Following is a fragment of a token contract to demonstrate how a token contract maintains the token balance of Ethereum accounts:
+
以下は、トークン契約がEthereumアカウントのトークンバランスをどのように維持するかを示すためのトークン契約の断片です:
  
<syntaxhighlight lang="javascript" line='line'>
+
<syntaxhighlight lang = "javascript" line = 'line'>
contract TokenContractFragment {
+
契約TokenContractFragment {
+
 
    // Balances for each account
+
    //各口座の残高
    mapping(address => uint256) balances;
+
    マッピング(アドレス=> uint256)のバランス。
+
 
    // Owner of account approves the transfer of an amount to another account
+
    //所有者が金額を別の口座に振り替えることを承認する
    mapping(address => mapping (address => uint256)) allowed;
+
    マッピング(アドレス=>マッピング(アドレス=> uint256))は許可されています。
+
 
    // Get the token balance for account `tokenOwner`
+
    //アカウント `tokenOwner`のトークン残高を取得する
    function balanceOf(address tokenOwner) public constant returns (uint balance) {
+
    関数balanceOf(address tokenOwner)public定数が返す(uint balance){
        return balances[tokenOwner];
+
        リターンバランス[tokenOwner];
    }
+
    }
+
 
    // Transfer the balance from owner's account to another account
+
    //所有者のアカウントから別のアカウントに残高を転送する
    function transfer(address to, uint tokens) public returns (bool success) {
+
    関数の転送(アドレスto、uintトークン)public returns(bool success){
        balances[msg.sender] = balances[msg.sender].sub(tokens);
+
        バランス[msg.sender] =バランス[msg.sender] .sub(トークン);
        balances[to] = balances[to].add(tokens);
+
        バランス[to] =バランス[to] .add(tokens);
        Transfer(msg.sender, to, tokens);
+
        転送(msg.sender、to、tokens);
        return true;
+
        真を返します。
    }
+
    }
+
 
    // Send `tokens` amount of tokens from address `from` to address `to`
+
    //「from」から「to」にトークン量のトークンを送る
    // The transferFrom method is used for a withdraw workflow, allowing contracts to send
+
    // transferFromメソッドは、引き出しワークフローに使用され、契約の送信を許可します
    // tokens on your behalf, for example to "deposit" to a contract address and/or to charge
+
    //あなたの代理として、たとえば契約アドレスに「入金する」、および/または請求するためのトークン
    // fees in sub-currencies; the command should fail unless the _from account has
+
    //副通貨での手数料。 _fromアカウントが持っていない限りコマンドは失敗するはずです
    // deliberately authorized the sender of the message via some mechanism; we propose
+
    //意図的にメッセージの送信者を何らかのメカニズムで承認しました。私達は提案します
    // these standardized APIs for approval:
+
    //承認のためのこれらの標準化されたAPI:
    function transferFrom(address from, address to, uint tokens) public returns (bool success) {
+
    function transferFrom(アドレス、アドレス、uintトークンからのアドレス)public returns(bool success){
        balances[from] = balances[from].sub(tokens);
+
        バランス[from] =バランス[from] .sub(tokens);
        allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
+
        許可[from] [msg.sender] =許可[from] [msg.sender] .sub(tokens);
        balances[to] = balances[to].add(tokens);
+
        バランス[to] =バランス[to] .add(tokens);
        Transfer(from, to, tokens);
+
        転送(from、to、トークン)。
        return true;
+
        真を返します。
    }
+
    }
+
 
    // Allow `spender` to withdraw from your account, multiple times, up to the `tokens` amount.
+
    //あなたの口座から `spender 'が` tokens`金額まで何回も引き出す​​ことを許可します。
    // If this function is called again it overwrites the current allowance with _value.
+
    //この関数をもう一度呼び出すと、現在の余裕が_valueで上書きされます。
    function approve(address spender, uint tokens) public returns (bool success) {
+
    関数は承認されます(出産者、住所トークン)public returns(bool success){
        allowed[msg.sender][spender] = tokens;
+
        [msg.sender] [spender] =トークンを許可しました。
        Approval(msg.sender, spender, tokens);
+
        承認(msg.sender、spender、tokens);
        return true;
+
        真を返します。
    }
+
    }
}  
+
}
</syntaxhighlight>
+
</ syntaxhighlight>
  
===Token Balance===
+
===トークンバランス===
For an example, assume that this token contract has two token holders:
+
たとえば、このトークンコントラクトに2つのトークンホルダがあるとします。
* <code>0x1111111111111111111111111111111111111111</code> with a balance of 100 units
+
* <code> 0x1111111111111111111111111111111111111111 </ code>の残高は100単位です
* <code>0x2222222222222222222222222222222222222222</code> with a balance of 200 units
+
* <code> 0x2222222222222222222222222222222222222222 </ code>、残高は200単位
  
The token contract's <code>balances</code> data structure will contain the following information:
+
トークンコントラクトの<code> balance </ code>データ構造には、次の情報が含まれます。
balances[0x1111111111111111111111111111111111111111] = 100
+
 残高[0x1111111111111111111111111111111111111111] = 100
balances[0x2222222222222222222222222222222222222222] = 200
+
 残高[0x2222222222222222222222222222222222222222] = 200
  
The <code>balanceOf(...)</code> function will return the following values:
+
<code> balanceOf(...</ code>関数は、次の値を返します。
tokenContract.balanceOf(0x1111111111111111111111111111111111111111) will return 100
+
 tokenContract.balanceOf(0x1111111111111111111111111111111111111111)は100を返します。
tokenContract.balanceOf(0x2222222222222222222222222222222222222222) will return 200
+
 tokenContract.balanceOf(0x222222222222222222222222222222222222222222)は200を返します
  
===Transfer Token Balance===
+
===転送トークンバランス===
If <code>0x1111111111111111111111111111111111111111</code> wants to transfer 10 tokens to <code>0x2222222222222222222222222222222222222222</code>, <code>0x1111111111111111111111111111111111111111</code> will execute the function:
+
<code> 0x1111111111111111111111111111111111111111 </ code>が10個のトークンを<code> 0x2222222222222222222222222222222222222222 </ code>に転送したい場合、<code> 0x1111111111111111111111111111111111111111 </ code>
tokenContract.transfer(0x2222222222222222222222222222222222222222, 10)
+
 tokenContract.transfer(0x222222222222222222222222222222222222222222,10)
  
The token contract's <code>transfer(...)</code> function will alter the <code>balances</code> data structure to contain the following information:
+
トークン契約の<code> transfer(...</ code>関数は、<code> balance </ code>データ構造を変更して次の情報を格納します。
balances[0x1111111111111111111111111111111111111111] = 90
+
 残高[0x1111111111111111111111111111111111111111] = 90
balances[0x2222222222222222222222222222222222222222] = 210
+
 残高[0x2222222222222222222222222222222222222222] = 210
  
The <code>balanceOf(...)</code> function will now return the following values:
+
<code> balanceOf(...</ code>関数は次の値を返します。
tokenContract.balanceOf(0x1111111111111111111111111111111111111111) will return 90
+
 tokenContract.balanceOf(0x1111111111111111111111111111111111111111)は90を返します
tokenContract.balanceOf(0x2222222222222222222222222222222222222222) will return 210
+
 tokenContract.balanceOf(0x222222222222222222222222222222222222222222)は210を返します
  
===Approve And TransferFrom Token Balance===
+
===トークンバランスを承認してから転送する===
If <code>0x1111111111111111111111111111111111111111</code> wants to authorise <code>0x2222222222222222222222222222222222222222</code> to transfer some tokens to <code>0x2222222222222222222222222222222222222222</code>, <code>0x1111111111111111111111111111111111111111</code> will execute the function:
+
<code> 0x1111111111111111111111111111111111111111 </ code><code> 0x22222222222222222222222222222222222222 </ code>にいくつかのトークンを<code> 0x2222222222222222222222222222222222222222222222222222 </ code>に転送することを許可したい場合、<code> 0x1111111111111111111111111111111111111111 </ code>
tokenContract.approve(0x2222222222222222222222222222222222222222, 30)
+
 tokenContract.approve(0x222222222222222222222222222222222222222222,30)
  
The <code>approve</code> data structure will now contain the following information:
+
<code>承認</ code>データ構造に次の情報が含まれるようになりました。
tokenContract.allowed[0x1111111111111111111111111111111111111111][0x2222222222222222222222222222222222222222] = 30
+
 tokenContract.allowed [0x1111111111111111111111111111111111111111] [0x22222222222222222222222222222222222222] = 30
  
If <code>0x2222222222222222222222222222222222222222</code> wants to later transfer some tokens from <code>0x1111111111111111111111111111111111111111</code> to itself, <code>0x2222222222222222222222222222222222222222</code> executes the <code>transferFrom(...)</code> function:
+
<code> 0x2222222222222222222222222222222222222222 </ code>が後で<code> 0x1111111111111111111111111111111111111111 </ code>からそれ自身にいくつかのトークンを転送したい場合、<code> 0x22222222222222222222222222222222222222 </ code><code> transferFrom(...</ code>関数:
tokenContract.transferFrom(0x1111111111111111111111111111111111111111, 0x2222222222222222222222222222222222222222, 20)
+
 tokenContract.transferFrom(0x1111111111111111111111111111111111111111,0x2222222222222222222222222222222222222222,20)
  
The <code>balances</code> data structure will be altered to contain the following information:
+
<code> balance </ code>データ構造は、次の情報を含むように変更されます。
tokenContract.balances[0x1111111111111111111111111111111111111111] = 70
+
 tokenContract.balances [0x1111111111111111111111111111111111111111] = 70
tokenContract.balances[0x2222222222222222222222222222222222222222] = 230
+
 tokenContract.balances [0x2222222222222222222222222222222222222222] = 230
  
And the <code>approve</code> data structure will now contain the following information:
+
また、<code>承認</ code>データ構造には次の情報が含まれます:
tokenContract.allowed[0x1111111111111111111111111111111111111111][0x2222222222222222222222222222222222222222] = 10
+
 tokenContract.allowed [0x1111111111111111111111111111111111111111] [0x2222222222222222222222222222222222222222] = 10
<code>0x2222222222222222222222222222222222222222</code> can still spend 10 tokens from <code>0x1111111111111111111111111111111111111111</code>.
+
<code> 0x2222222222222222222222222222222222222222 </ code>は、<code> 0x1111111111111111111111111111111111111111 </ code>から10トークンを引き続き使用できます。
  
The <code>balanceOf(...)</code> function will now return the following values:
+
<code> balanceOf(...</ code>関数は次の値を返します。
tokenContract.balanceOf(0x1111111111111111111111111111111111111111) will return 70
+
 tokenContract.balanceOf(0x1111111111111111111111111111111111111111)は70を返します
tokenContract.balanceOf(0x2222222222222222222222222222222222222222) will return 230
+
 tokenContract.balanceOf(0x222222222222222222222222222222222222222222)は230を返します。
  
 
<br />
 
<br />
  
==Sample Fixed Supply Token Contract==
+
==サンプル固定供給トークン契約==
Following is a sample [https://github.com/bokkypoobah/Tokens#fixed-supply-token Fixed Supply Token] contract with a fixed supply of 1,000,000 units that are initially assigned to the owner of the contract. This token has 18 decimal places:
+
以下は、最初に契約の所有者に割り当てられた1,000,000単位の固定供給でのサンプル[https://github.com/bokkypoobah/Tokens#fixed-supply-token固定供給トークン]契約です。このトークンの小数点以下は18桁です。
  
<syntaxhighlight lang="javascript" line='line'>
+
<syntaxhighlight lang = "javascript" line = 'line'>
pragma solidity ^0.4.18;
+
プラグマ硬度^ 0.4.18;
  
// ----------------------------------------------------------------------------
+
// ------------------------------------------------ ----------------------------
// 'FIXED' 'Example Fixed Supply Token' token contract
+
// 'FIXED' 'Example Fixed Supply Token'トークン契約
 
//
 
//
// Symbol      : FIXED
+
//シンボル:FIXED
// Name        : Example Fixed Supply Token
+
// Name:固定サプライトークンの例
// Total supply: 1,000,000.000000000000000000
+
//合計供給:1,000,000.000000000000000000
// Decimals    : 18
+
//小数点以下:18
 
//
 
//
// Enjoy.
+
// 楽しい。
 
//
 
//
// (c) BokkyPooBah / Bok Consulting Pty Ltd 2017. The MIT Licence.
+
//(c)BokkyPooBah / Bok Consulting Pty Ltd 2017. MITライセンス。
 +
// ------------------------------------------------ ----------------------------
 
// ----------------------------------------------------------------------------
 
// ----------------------------------------------------------------------------
 
+
//安全な数学
 
+
// ------------------------------------------------ ----------------------------
// ----------------------------------------------------------------------------
+
ライブラリSafeMath {
// Safe maths
+
    関数add(uint a、uint b)内部純戻り(uint c){
// ----------------------------------------------------------------------------
+
        c = a + b;
library SafeMath {
+
        require(c> = a);
    function add(uint a, uint b) internal pure returns (uint c) {
+
    }
        c = a + b;
+
    関数sub(uint a、uint b)内部純戻り値(uint c){
        require(c >= a);
+
        require(b <= a);
    }
+
        c = a-b;
    function sub(uint a, uint b) internal pure returns (uint c) {
+
    }
        require(b <= a);
+
    関数mul(uint a、uint b)内部純粋な戻り値(uint c){
        c = a - b;
+
        c = a * b;
    }
+
        require(a == 0 || c / a == b);
    function mul(uint a, uint b) internal pure returns (uint c) {
+
    }
        c = a * b;
+
    関数div(uint a、uint b)内部純戻り値(uint c){
        require(a == 0 || c / a == b);
+
        require(b> 0);
    }
+
        c = a / b;
    function div(uint a, uint b) internal pure returns (uint c) {
+
    }
        require(b > 0);
 
        c = a / b;
 
    }
 
 
}
 
}
  
  
// ----------------------------------------------------------------------------
+
// ------------------------------------------------ ----------------------------
// ERC Token Standard #20 Interface
+
// ERCトークン標準#20インタフェース
 
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
 
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// ----------------------------------------------------------------------------
+
// ------------------------------------------------ ----------------------------
contract ERC20Interface {
+
契約ERC20Interface {
    function totalSupply() public constant returns (uint);
+
    function totalSupply()public定数が返す値(uint)です。
    function balanceOf(address tokenOwner) public constant returns (uint balance);
+
    function balanceOf(address tokenOwner)public定数が返されます(uintバランス)。
    function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
+
    function allowance(アドレスtokenOwner、address spender)public定数は(uintの残りの部分)を返します。
    function transfer(address to, uint tokens) public returns (bool success);
+
    関数呼び出し(アドレスto、uintトークン)public return(bool success);
    function approve(address spender, uint tokens) public returns (bool success);
+
    機能は承認されます(払い戻し、uintトークン)public return(bool success);
    function transferFrom(address from, address to, uint tokens) public returns (bool success);
+
    function transferFrom(アドレス、アドレス、uintトークンからのアドレス)public returns(bool success);
  
    event Transfer(address indexed from, address indexed to, uint tokens);
+
    イベント転送(uintトークンにインデックス付けされたアドレス、uintトークンにインデックス付けされたアドレス)。
    event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
+
    イベント承認(アドレス指定されたtokenOwner、住所付き出費、uintトークン)。
 
}
 
}
  
  
// ----------------------------------------------------------------------------
+
// ------------------------------------------------ ----------------------------
// Contract function to receive approval and execute function in one call
+
// 1回の呼び出しで承認を受け取り、関数を実行するための契約関数
 
//
 
//
// Borrowed from MiniMeToken
+
// MiniMeTokenから借用
// ----------------------------------------------------------------------------
+
// ------------------------------------------------ ----------------------------
contract ApproveAndCallFallBack {
+
契約ApproveAndCallFallBack {
    function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
+
    関数receiveApproval(uint256トークンからのアドレス、アドレストークン、バイトデータ)public;
 
}
 
}
  
  
// ----------------------------------------------------------------------------
+
// ------------------------------------------------ ----------------------------
// Owned contract
+
//所有契約
// ----------------------------------------------------------------------------
+
// ------------------------------------------------ ----------------------------
contract Owned {
+
契約所有者{
    address public owner;
+
    公的所有者に対処する。
    address public newOwner;
+
    アドレスpublic newOwner;
  
    event OwnershipTransferred(address indexed _from, address indexed _to);
+
    イベントOwnershipTransferred(アドレス指定されたアドレス_from、アドレス指定されたアドレス_to)。
  
    function Owned() public {
+
    関数Owned()public {
        owner = msg.sender;
+
        owner = msg.sender;
    }
+
    }
  
    modifier onlyOwner {
+
    修飾子onlyOwner {
        require(msg.sender == owner);
+
        require(msg.sender == owner);
        _;
+
        _;
    }
+
    }
  
    function transferOwnership(address _newOwner) public onlyOwner {
+
    関数transferOwnership(アドレス_newOwner)public onlyOwner {
        newOwner = _newOwner;
+
        newOwner = _newOwner;
    }
+
    }
    function acceptOwnership() public {
+
    関数acceptOwnership()public {
        require(msg.sender == newOwner);
+
        require(msg.sender == newOwner);
        OwnershipTransferred(owner, newOwner);
+
        OwnershipTransferred(owner、newOwner);
        owner = newOwner;
+
        オーナー= newOwner;
        newOwner = address(0);
+
        newOwner =アドレス(0);
    }
+
    }
 
}
 
}
  
  
// ----------------------------------------------------------------------------
+
// ------------------------------------------------ ----------------------------
// ERC20 Token, with the addition of symbol, name and decimals and an
+
// ERC20トークン。シンボル、名前、および小数点を追加します。
// initial fixed supply
+
//最初の固定供給
// ----------------------------------------------------------------------------
+
// ------------------------------------------------ ----------------------------
contract FixedSupplyToken is ERC20Interface, Owned {
+
契約FixedSupplyTokenはERC20Interface、Owned {
    using SafeMath for uint;
+
    uintにはSafeMathを使用します。
 
 
    string public symbol;
 
    string public  name;
 
    uint8 public decimals;
 
    uint public _totalSupply;
 
  
    mapping(address => uint) balances;
+
    文字列public symbol;
    mapping(address => mapping(address => uint)) allowed;
+
    文字列public name;
 +
    uint8 public decimals;
 +
    uint public _totalSupply;
  
 +
    マッピング(アドレス=> uint)のバランス。
 +
    マッピング(アドレス=>マッピング(アドレス=> uint))。
  
    // ------------------------------------------------------------------------
 
    // Constructor
 
    // ------------------------------------------------------------------------
 
    function FixedSupplyToken() public {
 
        symbol = "FIXED";
 
        name = "Example Fixed Supply Token";
 
        decimals = 18;
 
        _totalSupply = 1000000 * 10**uint(decimals);
 
        balances[owner] = _totalSupply;
 
        Transfer(address(0), owner, _totalSupply);
 
    }
 
  
 +
  // ------------------------------------------------ ------------------------
 +
    //コンストラクタ
 +
    // ------------------------------------------------ ------------------------
 +
    function FixedSupplyToken()public {
 +
        シンボル= "FIXED";
 +
        name = "固定供給トークンの例";
 +
        小数点= 18;
 +
        _totalSupply = 1000000 * 10 ** uint(小数点以下)。
 +
        バランス[所有者] = _totalSupply;
 +
        転送(アドレス(0)、所有者、_totalSupply);
 +
    }
  
    // ------------------------------------------------------------------------
 
    // Total supply
 
    // ------------------------------------------------------------------------
 
    function totalSupply() public constant returns (uint) {
 
        return _totalSupply  - balances[address(0)];
 
    }
 
  
 +
    // ------------------------------------------------ ------------------------
 +
    //合計供給
 +
    // ------------------------------------------------ ------------------------
 +
    function totalSupply()public定数が返されます(uint){
 +
        return _totalSupply - バランス[住所(0)];
 +
    }
  
    // ------------------------------------------------------------------------
 
    // Get the token balance for account `tokenOwner`
 
    // ------------------------------------------------------------------------
 
    function balanceOf(address tokenOwner) public constant returns (uint balance) {
 
        return balances[tokenOwner];
 
    }
 
  
 +
    // ------------------------------------------------ ------------------------
 +
    //アカウント `tokenOwner`のトークン残高を取得する
 +
    // ------------------------------------------------ ------------------------
 +
    関数balanceOf(address tokenOwner)public定数が返す(uint balance){
 +
        リターンバランス[tokenOwner];
 +
    }
  
    // ------------------------------------------------------------------------
 
    // Transfer the balance from token owner's account to `to` account
 
    // - Owner's account must have sufficient balance to transfer
 
    // - 0 value transfers are allowed
 
    // ------------------------------------------------------------------------
 
    function transfer(address to, uint tokens) public returns (bool success) {
 
        balances[msg.sender] = balances[msg.sender].sub(tokens);
 
        balances[to] = balances[to].add(tokens);
 
        Transfer(msg.sender, to, tokens);
 
        return true;
 
    }
 
  
 +
    // ------------------------------------------------ ------------------------
 +
    //トークン所有者の口座から残高を `to`口座に振り替えます
 +
    // - オーナーのアカウントには、転送に十分な残高が必要です
 +
    // - 0の値の転送は許可されます
 +
    // ------------------------------------------------ ------------------------
 +
    関数の転送(アドレスto、uintトークン)public returns(bool success){
 +
        バランス[msg.sender] =バランス[msg.sender] .sub(トークン);
 +
        バランス[to] =バランス[to] .add(tokens);
 +
        転送(msg.sender、to、tokens);
 +
        真を返します。
 +
    }
  
    // ------------------------------------------------------------------------
 
    // Token owner can approve for `spender` to transferFrom(...) `tokens`
 
    // from the token owner's account
 
    //
 
    // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
 
    // recommends that there are no checks for the approval double-spend attack
 
    // as this should be implemented in user interfaces
 
    // ------------------------------------------------------------------------
 
    function approve(address spender, uint tokens) public returns (bool success) {
 
        allowed[msg.sender][spender] = tokens;
 
        Approval(msg.sender, spender, tokens);
 
        return true;
 
    }
 
  
 +
    // ------------------------------------------------ ------------------------
 +
    //トークンの所有者は、 `spender`が` token 'をtransferFrom(...)することを承認できます
 +
    //トークン所有者のアカウントから
 +
    //
 +
    // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
 +
    //承認重複攻撃のチェックがないことを推奨します
 +
    //これはユーザーインターフェイスで実装する必要があるため
 +
    // ------------------------------------------------ ------------------------
 +
    関数は承認されます(出産者、住所トークン)public returns(bool success){
 +
        [msg.sender] [spender] =トークンを許可しました。
 +
        承認(msg.sender、spender、tokens);
 +
        真を返します。
 +
    }
  
    // ------------------------------------------------------------------------
 
    // Transfer `tokens` from the `from` account to the `to` account
 
    //
 
    // The calling account must already have sufficient tokens approve(...)-d
 
    // for spending from the `from` account and
 
    // - From account must have sufficient balance to transfer
 
    // - Spender must have sufficient allowance to transfer
 
    // - 0 value transfers are allowed
 
    // ------------------------------------------------------------------------
 
    function transferFrom(address from, address to, uint tokens) public returns (bool success) {
 
        balances[from] = balances[from].sub(tokens);
 
        allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
 
        balances[to] = balances[to].add(tokens);
 
        Transfer(from, to, tokens);
 
        return true;
 
    }
 
  
 +
    // ------------------------------------------------ ------------------------
 +
    // `to`アカウントから` to`アカウントに `tokens`を転送します
 +
    //
 +
    //呼び出し元のアカウントには、十分なトークンがすでに承認されている必要があります(...) - d
 +
    //「from」アカウントからの支出と
 +
    // - 口座から転送に十分な残高がある必要があります
 +
    // - Spenderは転送に十分な余裕を持っていなければなりません
 +
    // - 0の値の転送は許可されます
 +
    // ------------------------------------------------ ------------------------
 +
    function transferFrom(アドレス、アドレス、uintトークンからのアドレス)public returns(bool success){
 +
        バランス[from] =バランス[from] .sub(tokens);
 +
        許可[from] [msg.sender] =許可[from] [msg.sender] .sub(tokens);
 +
        バランス[to] =バランス[to] .add(tokens);
 +
        転送(from、to、トークン)。
 +
        真を返します。
 +
    }
  
    // ------------------------------------------------------------------------
 
    // Returns the amount of tokens approved by the owner that can be
 
    // transferred to the spender's account
 
    // ------------------------------------------------------------------------
 
    function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
 
        return allowed[tokenOwner][spender];
 
    }
 
  
 +
    // ------------------------------------------------ ------------------------
 +
    //所有者が承認したトークンの量を返します。
 +
    //振込先の口座に振り込まれる
 +
    // ------------------------------------------------ ------------------------
 +
    機能許可(アドレスtokenOwner、アドレスspender)public constant returns(uint remaining){
 +
        戻り値[tokenOwner] [spender];
 +
    }
  
    // ------------------------------------------------------------------------
 
    // Token owner can approve for `spender` to transferFrom(...) `tokens`
 
    // from the token owner's account. The `spender` contract function
 
    // `receiveApproval(...)` is then executed
 
    // ------------------------------------------------------------------------
 
    function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
 
        allowed[msg.sender][spender] = tokens;
 
        Approval(msg.sender, spender, tokens);
 
        ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
 
        return true;
 
    }
 
  
 +
    // ------------------------------------------------ ------------------------
 +
    //トークンの所有者は、 `spender`が` token 'をtransferFrom(...)することを承認できます
 +
    //トークン所有者のアカウントから取得します。 「浪費」契約機能
 +
    // `receiveApproval(...)`が実行されます
 +
    // ------------------------------------------------ ------------------------
 +
    関数approveAndCall(払い出し、uintトークン、バイトデータ)public returns(bool success){
 +
        [msg.sender] [spender] =トークンを許可しました。
 +
        承認(msg.sender、spender、tokens);
 +
        ApproveAndCallFallBack(spender).receiveApproval(msg.sender、tokens、this、data);
 +
        真を返します。
 +
    }
  
    // ------------------------------------------------------------------------
+
  // ------------------------------------------------ ------------------------
    // Don't accept ETH
+
    // ETHを受け付けない
    // ------------------------------------------------------------------------
+
    // ------------------------------------------------ ------------------------
    function () public payable {
+
    function()public payable {
        revert();
+
        revert();
    }
+
    }
  
  
    // ------------------------------------------------------------------------
+
    // ------------------------------------------------ ------------------------
    // Owner can transfer out any accidentally sent ERC20 tokens
+
    //所有者は、誤って送信されたERC20トークンを転送できます
    // ------------------------------------------------------------------------
+
    // ------------------------------------------------ ------------------------
    function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
+
    function transferAnyERC20Token(アドレスtokenAddress、uintトークン)public onlyOwnerは(ブール成功)を返します{
        return ERC20Interface(tokenAddress).transfer(owner, tokens);
+
        ERC20Interface(tokenAddress).transfer(owner、tokens)を返します。
    }
+
    }
 
}
 
}
</syntaxhighlight>
+
</ syntaxhighlight>
  
See [https://medium.com/bitfwd/how-to-issue-your-own-token-on-ethereum-in-less-than-20-minutes-ac1f8f022793 How to issue your own token on Ethereum in less than 20 minutes] for steps to deploy a token contract.
+
[https://medium.com/bitfwd/how-to-issue-your-own-token-on-ethereum-in-less-than-20-minutes-ac1f8f022793を参照してください。Ethereumで独自のトークンを発行する方法トークン契約を展開する手順は、「20分」を参照してください。
  
==Further Information On Ethereum Tokens==
+
== Ethereumトークンに関する詳細==
  
* Ethereum.org Token page: https://www.ethereum.org/token.
+
* Ethereum.orgトークンページ:https://www.ethereum.org/token。
* Etherscan token selection of popular tokens: https://etherscan.io/tokens
+
*人気のあるトークンのEtherscanトークンの選択:https://etherscan.io/tokens
* EtherScan ERC20 token search: https://etherscan.io/token-search
+
* EtherScan ERC20トークン検索:https://etherscan.io/token-search
* The HumanStandardToken: a specialisation of ERC20 that provides a name, decimals, symbol  and version as public variables, so these can be read from the contract and do not need to be configured: https://github.com/ConsenSys/Tokens/blob/master/Token_Contracts/contracts/HumanStandardToken.sol
+
* HumanStandardToken:名前、小数点記号、シンボル、バージョンを公開変数として提供するERC20の特化版で、契約書から読むことができ、設定する必要はありません:https://github.com/ConsenSys/Tokens/ blob / master / Token_Contracts / contracts / HumanStandardToken.sol
* Token Factory, an application that lets you create these tokens, just to play around with: https://tokenfactory.surge.sh
+
トークンファクトリ。これらのトークンを作成できるアプリケーションで、https://tokenfactory.surge.shで遊ぶだけです。
* Libraries:
+
*ライブラリ:
** OpenZeppelin: https://github.com/OpenZeppelin/zeppelin-solidity/tree/master/contracts/token
+
** OpenZeppelin:https://github.com/OpenZeppelin/zeppelin-solidity/tree/master/contracts/token
** Minime token contract  that allows to clone itself, so it can be used for things like voting, or even splitting off a token for a separate application: https://github.com/Giveth/minime
+
**クローン自体を許可するMinimeトークンコントラクト。投票のようなものや別のアプリケーションのトークンを分割することもできます:https://github.com/Giveth/minime
  
==See also==
+
==関連項目==
 
* [[Ethereum Based Tokens]]
 
* [[Ethereum Based Tokens]]
 
* [[ERC20 Wallet Support]]
 
* [[ERC20 Wallet Support]]
* [[Mining]]
+
* [マイニング]
 
* [[BTC China]]
 
* [[BTC China]]
 
* [[CEX.IO]]
 
* [[CEX.IO]]
  
==Source==
+
==ソース==
  
 
[http://wikipedia.org/ http://wikipedia.org/]
 
[http://wikipedia.org/ http://wikipedia.org/]

2018年4月18日 (水) 22:59時点における最新版

テンプレートのループを検出しました: テンプレート:#

Ethereum [スマートコントラクト|スマートコントラクト]にはEthereumトークン標準( 'ERC20' )が使用されています。 2015年に開発されたERC-20は、Ethereumトークンが実装しなければならないルールの共通リストを定義しています。開発者に、新しいトークンがEthereumエコシステム内でどのように機能するかをプログラムする能力を与える。このトークンプロトコルは、 Initial Coin Offering(ICO)を通じてクラウドファンディング企業に人気がありました。

Mercury Protocolのグローバル・メッセージング・トークンは、ERC20トークンに基づくアプリケーションの例です。

ERC20トークン標準は、Ethereumトークン契約が実装しなければならない機能とイベントを記述します。

ERC20トークン標準インタフェース[編集]

以下は、ERC20規格を満たすために必要な機能とイベントを宣言するインタフェース契約です。

<syntaxhighlight lang = "javascript" line = 'line'> // ------------------------------------------------ ---------------------------- // ERCトークン標準#20インタフェース // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ------------------------------------------------ ---------------------------- 契約ERC20Interface {     function totalSupply()public定数が返す値(uint)です。     function balanceOf(address tokenOwner)public定数が返されます(uintバランス)。     function allowance(アドレスtokenOwner、address spender)public定数は(uintの残りの部分)を返します。     関数呼び出し(アドレスto、uintトークン)public return(bool success);     機能は承認されます(払い戻し、uintトークン)public return(bool success);     function transferFrom(アドレス、アドレス、uintトークンからのアドレス)public returns(bool success);

    イベント転送(uintトークンにインデックス付けされたアドレス、uintトークンにインデックス付けされたアドレス)。     イベント承認(アドレス指定されたtokenOwner、住所付き出費、uintトークン)。 } </ syntaxhighlight>

Ethereumブロックチェーンの主要なトークンのほとんどはERC20に準拠しています。 allowance(..)</ code>、<code> allowance(..)</ code>を実装していないため、GNT Golem Network Tokenは、 code>および<code> transferFrom(...)</ code>関数、および<code> Approval(...)</ code>イベントを生成します。

トークンの一部には、トークン契約を説明する追加情報が含まれています。

<syntaxhighlight lang = "javascript" line = 'line'>     文字列public constant name = "トークン名";     文字列public constant symbol = "SYM";     uint8 public定数decimals = 18; // 18は最も一般的な小数点以下の桁数です </ syntaxhighlight>


トークン契約はどのように機能するのですか?[編集]

以下は、トークン契約がEthereumアカウントのトークンバランスをどのように維持するかを示すためのトークン契約の断片です:

<syntaxhighlight lang = "javascript" line = 'line'> 契約TokenContractFragment {       //各口座の残高     マッピング(アドレス=> uint256)のバランス。       //所有者が金額を別の口座に振り替えることを承認する     マッピング(アドレス=>マッピング(アドレス=> uint256))は許可されています。       //アカウント `tokenOwner`のトークン残高を取得する     関数balanceOf(address tokenOwner)public定数が返す(uint balance){         リターンバランス[tokenOwner];     }       //所有者のアカウントから別のアカウントに残高を転送する     関数の転送(アドレスto、uintトークン)public returns(bool success){         バランス[msg.sender] =バランス[msg.sender] .sub(トークン);         バランス[to] =バランス[to] .add(tokens);         転送(msg.sender、to、tokens);         真を返します。     }       //「from」から「to」にトークン量のトークンを送る     // transferFromメソッドは、引き出しワークフローに使用され、契約の送信を許可します     //あなたの代理として、たとえば契約アドレスに「入金する」、および/または請求するためのトークン     //副通貨での手数料。 _fromアカウントが持っていない限りコマンドは失敗するはずです     //意図的にメッセージの送信者を何らかのメカニズムで承認しました。私達は提案します     //承認のためのこれらの標準化されたAPI:     function transferFrom(アドレス、アドレス、uintトークンからのアドレス)public returns(bool success){         バランス[from] =バランス[from] .sub(tokens);         許可[from] [msg.sender] =許可[from] [msg.sender] .sub(tokens);         バランス[to] =バランス[to] .add(tokens);         転送(from、to、トークン)。         真を返します。     }       //あなたの口座から `spender 'が` tokens`金額まで何回も引き出す​​ことを許可します。     //この関数をもう一度呼び出すと、現在の余裕が_valueで上書きされます。     関数は承認されます(出産者、住所トークン)public returns(bool success){         [msg.sender] [spender] =トークンを許可しました。         承認(msg.sender、spender、tokens);         真を返します。     } } </ syntaxhighlight>

トークンバランス[編集]

たとえば、このトークンコントラクトに2つのトークンホルダがあるとします。

  • <code> 0x1111111111111111111111111111111111111111 </ code>の残高は100単位です
  • <code> 0x2222222222222222222222222222222222222222 </ code>、残高は200単位

トークンコントラクトの<code> balance </ code>データ構造には、次の情報が含まれます。  残高[0x1111111111111111111111111111111111111111] = 100  残高[0x2222222222222222222222222222222222222222] = 200

<code> balanceOf(...)</ code>関数は、次の値を返します。  tokenContract.balanceOf(0x1111111111111111111111111111111111111111)は100を返します。  tokenContract.balanceOf(0x222222222222222222222222222222222222222222)は200を返します

転送トークンバランス[編集]

<code> 0x1111111111111111111111111111111111111111 </ code>が10個のトークンを<code> 0x2222222222222222222222222222222222222222 </ code>に転送したい場合、<code> 0x1111111111111111111111111111111111111111 </ code>  tokenContract.transfer(0x222222222222222222222222222222222222222222,10)

トークン契約の<code> transfer(...)</ code>関数は、<code> balance </ code>データ構造を変更して次の情報を格納します。  残高[0x1111111111111111111111111111111111111111] = 90  残高[0x2222222222222222222222222222222222222222] = 210

<code> balanceOf(...)</ code>関数は次の値を返します。  tokenContract.balanceOf(0x1111111111111111111111111111111111111111)は90を返します  tokenContract.balanceOf(0x222222222222222222222222222222222222222222)は210を返します

トークンバランスを承認してから転送する[編集]

<code> 0x1111111111111111111111111111111111111111 </ code>が<code> 0x22222222222222222222222222222222222222 </ code>にいくつかのトークンを<code> 0x2222222222222222222222222222222222222222222222222222 </ code>に転送することを許可したい場合、<code> 0x1111111111111111111111111111111111111111 </ code>  tokenContract.approve(0x222222222222222222222222222222222222222222,30)

<code>承認</ code>データ構造に次の情報が含まれるようになりました。  tokenContract.allowed [0x1111111111111111111111111111111111111111] [0x22222222222222222222222222222222222222] = 30

<code> 0x2222222222222222222222222222222222222222 </ code>が後で<code> 0x1111111111111111111111111111111111111111 </ code>からそれ自身にいくつかのトークンを転送したい場合、<code> 0x22222222222222222222222222222222222222 </ code>は<code> transferFrom(...)</ code>関数:  tokenContract.transferFrom(0x1111111111111111111111111111111111111111,0x2222222222222222222222222222222222222222,20)

<code> balance </ code>データ構造は、次の情報を含むように変更されます。  tokenContract.balances [0x1111111111111111111111111111111111111111] = 70  tokenContract.balances [0x2222222222222222222222222222222222222222] = 230

また、<code>承認</ code>データ構造には次の情報が含まれます:  tokenContract.allowed [0x1111111111111111111111111111111111111111] [0x2222222222222222222222222222222222222222] = 10 <code> 0x2222222222222222222222222222222222222222 </ code>は、<code> 0x1111111111111111111111111111111111111111 </ code>から10トークンを引き続き使用できます。

<code> balanceOf(...)</ code>関数は次の値を返します。  tokenContract.balanceOf(0x1111111111111111111111111111111111111111)は70を返します  tokenContract.balanceOf(0x222222222222222222222222222222222222222222)は230を返します。


サンプル固定供給トークン契約[編集]

以下は、最初に契約の所有者に割り当てられた1,000,000単位の固定供給でのサンプル[1]契約です。このトークンの小数点以下は18桁です。

<syntaxhighlight lang = "javascript" line = 'line'> プラグマ硬度^ 0.4.18;

// ------------------------------------------------ ---------------------------- // 'FIXED' 'Example Fixed Supply Token'トークン契約 // //シンボル:FIXED // Name:固定サプライトークンの例 //合計供給:1,000,000.000000000000000000 //小数点以下:18 // // 楽しい。 // //(c)BokkyPooBah / Bok Consulting Pty Ltd 2017. MITライセンス。 // ------------------------------------------------ ---------------------------- // ---------------------------------------------------------------------------- //安全な数学 // ------------------------------------------------ ---------------------------- ライブラリSafeMath {     関数add(uint a、uint b)内部純戻り(uint c){         c = a + b;         require(c> = a);     }     関数sub(uint a、uint b)内部純戻り値(uint c){         require(b <= a);         c = a-b;     }     関数mul(uint a、uint b)内部純粋な戻り値(uint c){         c = a * b;         require(a == 0 || c / a == b);     }     関数div(uint a、uint b)内部純戻り値(uint c){         require(b> 0);         c = a / b;     } }


// ------------------------------------------------ ---------------------------- // ERCトークン標準#20インタフェース // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ------------------------------------------------ ---------------------------- 契約ERC20Interface {     function totalSupply()public定数が返す値(uint)です。     function balanceOf(address tokenOwner)public定数が返されます(uintバランス)。     function allowance(アドレスtokenOwner、address spender)public定数は(uintの残りの部分)を返します。     関数呼び出し(アドレスto、uintトークン)public return(bool success);     機能は承認されます(払い戻し、uintトークン)public return(bool success);     function transferFrom(アドレス、アドレス、uintトークンからのアドレス)public returns(bool success);

    イベント転送(uintトークンにインデックス付けされたアドレス、uintトークンにインデックス付けされたアドレス)。     イベント承認(アドレス指定されたtokenOwner、住所付き出費、uintトークン)。 }


// ------------------------------------------------ ---------------------------- // 1回の呼び出しで承認を受け取り、関数を実行するための契約関数 // // MiniMeTokenから借用 // ------------------------------------------------ ---------------------------- 契約ApproveAndCallFallBack {     関数receiveApproval(uint256トークンからのアドレス、アドレストークン、バイトデータ)public; }


// ------------------------------------------------ ---------------------------- //所有契約 // ------------------------------------------------ ---------------------------- 契約所有者{     公的所有者に対処する。     アドレスpublic newOwner;

    イベントOwnershipTransferred(アドレス指定されたアドレス_from、アドレス指定されたアドレス_to)。

    関数Owned()public {         owner = msg.sender;     }

    修飾子onlyOwner {         require(msg.sender == owner);         _;     }

    関数transferOwnership(アドレス_newOwner)public onlyOwner {         newOwner = _newOwner;     }     関数acceptOwnership()public {         require(msg.sender == newOwner);         OwnershipTransferred(owner、newOwner);         オーナー= newOwner;         newOwner =アドレス(0);     } }


// ------------------------------------------------ ---------------------------- // ERC20トークン。シンボル、名前、および小数点を追加します。 //最初の固定供給 // ------------------------------------------------ ---------------------------- 契約FixedSupplyTokenはERC20Interface、Owned {     uintにはSafeMathを使用します。

    文字列public symbol;     文字列public name;     uint8 public decimals;     uint public _totalSupply;

    マッピング(アドレス=> uint)のバランス。     マッピング(アドレス=>マッピング(アドレス=> uint))。


 // ------------------------------------------------ ------------------------

    //コンストラクタ     // ------------------------------------------------ ------------------------     function FixedSupplyToken()public {         シンボル= "FIXED";         name = "固定供給トークンの例";         小数点= 18;         _totalSupply = 1000000 * 10 ** uint(小数点以下)。         バランス[所有者] = _totalSupply;         転送(アドレス(0)、所有者、_totalSupply);     }


    // ------------------------------------------------ ------------------------     //合計供給     // ------------------------------------------------ ------------------------     function totalSupply()public定数が返されます(uint){         return _totalSupply - バランス[住所(0)];     }


    // ------------------------------------------------ ------------------------     //アカウント `tokenOwner`のトークン残高を取得する     // ------------------------------------------------ ------------------------     関数balanceOf(address tokenOwner)public定数が返す(uint balance){         リターンバランス[tokenOwner];     }


    // ------------------------------------------------ ------------------------     //トークン所有者の口座から残高を `to`口座に振り替えます     // - オーナーのアカウントには、転送に十分な残高が必要です     // - 0の値の転送は許可されます     // ------------------------------------------------ ------------------------     関数の転送(アドレスto、uintトークン)public returns(bool success){         バランス[msg.sender] =バランス[msg.sender] .sub(トークン);         バランス[to] =バランス[to] .add(tokens);         転送(msg.sender、to、tokens);         真を返します。     }


    // ------------------------------------------------ ------------------------     //トークンの所有者は、 `spender`が` token 'をtransferFrom(...)することを承認できます     //トークン所有者のアカウントから     //     // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md     //承認重複攻撃のチェックがないことを推奨します     //これはユーザーインターフェイスで実装する必要があるため     // ------------------------------------------------ ------------------------     関数は承認されます(出産者、住所トークン)public returns(bool success){         [msg.sender] [spender] =トークンを許可しました。         承認(msg.sender、spender、tokens);         真を返します。     }


    // ------------------------------------------------ ------------------------     // `to`アカウントから` to`アカウントに `tokens`を転送します     //     //呼び出し元のアカウントには、十分なトークンがすでに承認されている必要があります(...) - d     //「from」アカウントからの支出と     // - 口座から転送に十分な残高がある必要があります     // - Spenderは転送に十分な余裕を持っていなければなりません     // - 0の値の転送は許可されます     // ------------------------------------------------ ------------------------     function transferFrom(アドレス、アドレス、uintトークンからのアドレス)public returns(bool success){         バランス[from] =バランス[from] .sub(tokens);         許可[from] [msg.sender] =許可[from] [msg.sender] .sub(tokens);         バランス[to] =バランス[to] .add(tokens);         転送(from、to、トークン)。         真を返します。     }


    // ------------------------------------------------ ------------------------     //所有者が承認したトークンの量を返します。     //振込先の口座に振り込まれる     // ------------------------------------------------ ------------------------     機能許可(アドレスtokenOwner、アドレスspender)public constant returns(uint remaining){         戻り値[tokenOwner] [spender];     }


    // ------------------------------------------------ ------------------------     //トークンの所有者は、 `spender`が` token 'をtransferFrom(...)することを承認できます     //トークン所有者のアカウントから取得します。 「浪費」契約機能     // `receiveApproval(...)`が実行されます     // ------------------------------------------------ ------------------------     関数approveAndCall(払い出し、uintトークン、バイトデータ)public returns(bool success){         [msg.sender] [spender] =トークンを許可しました。         承認(msg.sender、spender、tokens);         ApproveAndCallFallBack(spender).receiveApproval(msg.sender、tokens、this、data);         真を返します。     }

  // ------------------------------------------------ ------------------------

    // ETHを受け付けない     // ------------------------------------------------ ------------------------     function()public payable {         revert();     }


    // ------------------------------------------------ ------------------------     //所有者は、誤って送信されたERC20トークンを転送できます     // ------------------------------------------------ ------------------------     function transferAnyERC20Token(アドレスtokenAddress、uintトークン)public onlyOwnerは(ブール成功)を返します{         ERC20Interface(tokenAddress).transfer(owner、tokens)を返します。     } } </ syntaxhighlight>

[https://medium.com/bitfwd/how-to-issue-your-own-token-on-ethereum-in-less-than-20-minutes-ac1f8f022793を参照してください。Ethereumで独自のトークンを発行する方法トークン契約を展開する手順は、「20分」を参照してください。

Ethereumトークンに関する詳細[編集]

トークンファクトリ。これらのトークンを作成できるアプリケーションで、https://tokenfactory.surge.shで遊ぶだけです。

関連項目[編集]

ソース[編集]

http://wikipedia.org/