美文网首页
Cryptozombie Part5

Cryptozombie Part5

作者: Olly_Zhang | 来源:发表于2018-11-10 14:01 被阅读0次

    A token on Ethereum is basically just a smart contract that follows some common rules --- namely it impletments a standard set of functions that all other token contracts share, such as transfer(address _to,uint 256 _value) and balanceOf(address _owner).

    Internally the smart contract usually has a mapping, mapping(address => uint256) balances, that keeps track of how much balance each address has.

    So basically a token is just a contract that keeps track of who owns how much of that token, and some functions so those users can transfer their tokens to other addresses.

    ERC721 tokens are not interchangeable since each one is assumed to be unique, and are not divisible. You can only trade them in whole units, and each one has a unique ID.

    ERC721 standard, multiple inheritance

    contractERC721{

      eventTransfer(addressindexed_from,addressindexed_to,uint256_tokenId);

    eventApproval(addressindexed_owner,addressindexed_approved,uint256_tokenId);

    functionbalanceOf(address_owner)publicviewreturns(uint256_balance);

      functionownerOf(uint256_tokenId)publicviewreturns(address_owner);

      functiontransfer(address_to,uint256_tokenId)public;

      functionapprove(address_to,uint256_tokenId)public;

      functiontakeOwnership(uint256_tokenId)public;

    }

    Note: The ERC721 standard is currently a draft, and there is no officially agreed-upon implementation yet.

    相关文章

      网友评论

          本文标题:Cryptozombie Part5

          本文链接:https://www.haomeiwen.com/subject/pwjzxqtx.html