EIP协议学习2

EIP协议学习2EIP-721 Specification
pragma solidity ^0.4.20;

/// @title ERC-721 Non-Fungible Token Standard
/// @dev See https://eips.ethereum.org/EIPS/eip-721
///  Note: the ERC-165 identifier for this interface is 0x80ac58cd.
interface ERC721 /* is ERC165 */ {
 /// @dev This emits when ownership of any NFT changes by any mechanism.
 ///  This event emits when NFTs are created (`from` == 0) and destroyed
 ///  (`to` == 0). Exception: during contract creation, any number of NFTs
 ///  may be created and assigned without emitting Transfer. At the time of
 ///  any transfer, the approved address for that NFT (if any) is reset to none.
 <在任何机制下,当NFT的所有权发生改变的时候会触发。在NFT创建(from=0)和销毁(to=0)的时候会触发该事件,在任何时候进行转移时,NFT批转的地址将会被重置为none>
 event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);

 /// @dev This emits when the approved address for an NFT is changed or
 ///  reaffirmed. The zero address indicates there is no approved address.
 ///  When a Transfer event emits, this also indicates that the approved
 ///  address for that NFT (if any) is reset to none.
 <这个事件在NFT的许可地址被更改或者重复确认的时候会触发,0地址代表没有许可的地址,当Transfer事件发生的时候,这也标志许可地址被重置为none>
 event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);

 /// @dev This emits when an operator is enabled or disabled for an owner.
 ///  The operator can manage all NFTs of the owner.
 <这个操作触发可以让owner拥有或者禁用对于所有NFT所有这的管理权>
 event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);

 /// @notice Count all NFTs assigned to an owner
 /// @dev NFTs assigned to the zero address are considered invalid, and this
 ///  function throws for queries about the zero address.
 /// @param _owner An address for whom to query the balance
 /// @return The number of NFTs owned by `_owner`, possibly zero
 <同EIP-20-balanceOf>
 function balanceOf(address _owner) external view returns (uint256);

 /// @notice Find the owner of an NFT
 /// @dev NFTs assigned to zero address are considered invalid, and queries
 ///  about them do throw.
 /// @param _tokenId The identifier for an NFT
 /// @return The address of the owner of the NFT
 <传入NTF代币的token,返回NFT拥有者的地址>
 function ownerOf(uint256 _tokenId) external view returns (address);

 /// @notice Transfers the ownership of an NFT from one address to another address
 /// @dev Throws unless `msg.sender` is the current owner, an authorized
 ///  operator, or the approved address for this NFT. Throws if `_from` is
 ///  not the current owner. Throws if `_to` is the zero address. Throws if
 ///  `_tokenId` is not a valid NFT. When transfer is complete, this function
 ///  checks if `_to` is a smart contract (code size > 0). If so, it calls
 ///  `onERC721Received` on `_to` and throws if the return value is not
 ///  `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`.
 /// @param _from The current owner of the NFT
 /// @param _to The new owner
 /// @param _tokenId The NFT to transfer
 /// @param data Additional data with no specified format, sent in call to `_to`
 <如果消息发送方不是NFT许可地址或者授权的操作者,抛出异常;如果发送方不是当前的地址抛出异常;如果目标地址to是0地址抛出异常;如果tokenid不是有效的NFT标识,抛出异常;如果to地址对象是一个智能合约地址,那么必须要调用onERC721Received,如果返回值是no抛出异常>
 function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable;

 /// @notice Transfers the ownership of an NFT from one address to another address
 /// @dev This works identically to the other function with an extra data parameter,
 ///  except this function just sets data to "".
 /// @param _from The current owner of the NFT
 /// @param _to The new owner
 /// @param _tokenId The NFT to transfer
 <同上面一样,只是相当于将data设置为"">
 function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;

 /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
 ///  TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE
 ///  THEY MAY BE PERMANENTLY LOST
 /// @dev Throws unless `msg.sender` is the current owner, an authorized
 ///  operator, or the approved address for this NFT. Throws if `_from` is
 ///  not the current owner. Throws if `_to` is the zero address. Throws if
 ///  `_tokenId` is not a valid NFT.
 /// @param _from The current owner of the NFT
 /// @param _to The new owner
 /// @param _tokenId The NFT to transfer
 <同上面safeTransferFrom,缺少判断一个to为合约地址>
 function transferFrom(address _from, address _to, uint256 _tokenId) external payable;

 /// @notice Change or reaffirm the approved address for an NFT
 /// @dev The zero address indicates there is no approved address.
 ///  Throws unless `msg.sender` is the current NFT owner, or an authorized
 ///  operator of the current owner.
 /// @param _approved The new approved NFT controller
 /// @param _tokenId The NFT to approve
 <0地址表示没有许可的地址,如果当前发送者不是NFT拥有者或者许可操作者,抛出异常>
 function approve(address _approved, uint256 _tokenId) external payable;

 /// @notice Enable or disable approval for a third party ("operator") to manage
 ///  all of `msg.sender`'s assets
 /// @dev Emits the ApprovalForAll event. The contract MUST allow
 ///  multiple operators per owner.
 /// @param _operator Address to add to the set of authorized operators
 /// @param _approved True if the operator is approved, false to revoke approval
 <发送ApprovalForAll事件,这个合同必须允许每个拥有者有多个操作者>
 function setApprovalForAll(address _operator, bool _approved) external;

 /// @notice Get the approved address for a single NFT
 /// @dev Throws if `_tokenId` is not a valid NFT.
 /// @param _tokenId The NFT to find the approved address for
 /// @return The approved address for this NFT, or the zero address if there is none
 <抛出tokenid不是正确NFT的异常,返回被NFT许可的地址,如果没有许可地址则返回0地址>
 function getApproved(uint256 _tokenId) external view returns (address);

 /// @notice Query if an address is an authorized operator for another address
 /// @param _owner The address that owns the NFTs
 /// @param _operator The address that acts on behalf of the owner
 /// @return True if `_operator` is an approved operator for `_owner`, false otherwise
 <检验operator是否有操作的权限,返回true或者false>
 function isApprovedForAll(address _owner, address _operator) external view returns (bool);
}

interface ERC165 {
 /// @notice Query if a contract implements an interface
 /// @param interfaceID The interface identifier, as specified in ERC-165
 /// @dev Interface identification is specified in ERC-165. This function
 ///  uses less than 30,000 gas.
 /// @return `true` if the contract implements `interfaceID` and
 ///  `interfaceID` is not 0xffffffff, `false` otherwise
 function supportsInterface(bytes4 interfaceID) external view returns (bool);
}

欢迎分享,转载请注明来源:内存溢出

原文地址:http://outofmemory.cn/langs/893803.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-14
下一篇2022-05-14

随机推荐

  • swift – AVAudioEngine在插入或拔出耳机时崩溃

    概述我正在我的iPhone6 Plus上测试我的audioApp,它在插入耳机后进入崩溃状态. AVAudioEngine,AVAudioMixer,AVAudioPlayerNode用于我的应用程序. 没有耳机的启动应用程序可以播放iPh

  • linux – 如何在编辑器中管道程序输出?

    概述我有我的程序生成一些数据.它会在标准错误中输出所有内容. 现在我想将输出重定向到一个新开始的文本编辑器,到启动时显示的主要未命名的编辑窗口.我试过vim和gedit没有成功. myprogram | geditmyprogram | g

    2022-05-25
    000
  • Arch Linux – apt-get update等效命令?

    概述404 Page Not Found!总结 以上是内存溢出为你收集整理的Arch Linux – apt-get update等效命令?全部内容,希望文章能

    2022-05-25
    000
  • 如何从Linux上的系统缓存中逐出文件?

    概述运行性能测试时,文件系统缓存命中或未命中会显着影响测试结果.因此,通常在运行此类测试之前,使用的文件将从系统缓存中逐出.如何在Linux上做到这一点?澄清:如果可能,解决方案不应要求root权限.最佳答案作为超级用户,您可以执行以下操作

    2022-05-25
    000
  • Linux中的扩展桌面

    概述我的目标是在 Windows中拥有一个扩展的桌面. Linux只使用我的第二台显示器作为镜像,这是没用的.我在google和SO上搜索了很多东西以获得正确的方法.我希望linux将我的显示器用于一个扩展桌面,而不是镜像.到目前为止,我还

    2022-05-25
    000
  • Linux:创建随机目录文件层次结构

    概述为了测试工具,我需要一个目录,其中包含深层嵌套结构中的一大堆不同的Office文件.我已将文件放在目录中,但现在需要创建一些随机嵌套的子目录并将其中的文件展开. 我可以坐下来用我选择的编程语言编写一个合适的程序,但我想知道是否有一个聪明

  • linux – 使用更多修饰符重新键入键盘

    概述我正在寻找一种方法来为键盘添加一个“布局”.我已经在使用一个使用altgr作为本地字母的布局.我要添加的是一个镜像右手侧键盘,通过大写锁定激活( http:xkcd.commirrorboard.xkb中描述了一个) 不幸的是,I

    2022-05-25
    000
  • 如何从C安全地转义字符串

    概述我正在编写一个简单的程序来浏览本地网络,并使用“system”将文件名传递给mplayer.但是,有时文件名包含空格或引号.显然,我可以编写自己的函数来逃避这些,但我不确定哪些角色需要或不需要转义.CRT或linux头文件中是否有一个函

    2022-05-25
    000
  • php– 使用互斥锁的Linux并发脚本

    概述在我的Linux服务器上,我需要同步多个脚本,用BASH和PHP编写,这样只有其中一个脚本能够启动一个系统关键的工作,这是一系列BASHPHP命令,这些工作会搞砸由两个或多个脚本同时执行.根据我在C中使用多线程的经验,我熟悉互斥锁

    2022-05-25
    000

发表评论

登录后才能评论

评论列表(0条)

    保存