公排互助拆分开发运营版丨拆分互助公排系统开发(逻辑项目)/玩法规则/详细方案/代码部署

简介: Applications that complete tasks through consensus mechanisms and blockchain platforms are inherently decentralized and do not rely on any centralized servers,promoting safer user transactions.

Applications that complete tasks through consensus mechanisms and blockchain platforms are inherently decentralized and do not rely on any centralized servers,promoting safer user transactions.

  contract ERC721 is IERC721,IERC165{

  mapping(bytes4=>bool)supportsInterfaces;

  bytes4 invalidID=0xffffffff;

  bytes4 constant ERC165_InterfaceID=0x01ffc9a7;//erc165

  bytes4 constant ERC721_InterfaceID=0x80ac58cd;//erc721

  mapping(address=>uint256)ercTokenCount;

  mapping(uint256=>address)ercTokenOwner;

  mapping(uint256=>address)ercTokenApproved;

  mapping(address=>mapping(address=>bool))ercOperatorForAll;

  using Address for address;

  constructor(){

  _registerInterface(ERC165_InterfaceID);

  _registerInterface(ERC721_InterfaceID);

  }

  //授权

  modifier canOperator(uint256 _tokenId){

  address owner=ercTokenOwner[_tokenId];

  require(msg.sender==owner||ercOperatorForAll[owner][msg.sender]);

  _;

  }

  modifier canTransfer(uint256 _tokenId,address _from){

  address owner=ercTokenOwner[_tokenId];

  require(owner==_from);

  require(msg.sender==owner||msg.sender==ercTokenApproved[_tokenId]||ercOperatorForAll[owner][msg.sender]);

  _;

  }

  function _registerInterface(bytes4 interfaceID)internal{

  supportsInterfaces[interfaceID]=true;

  }

  function supportsInterface(bytes4 interfaceID)override external view returns(bool){

  require(invalidID!=interfaceID);

  return supportsInterfaces[interfaceID];

  }

  //721

  function balanceOf(address _owner)override external view returns(uint256){

  return ercTokenCount[_owner];

  }

  function ownerOf(uint256 _tokenId)override external view returns(address){

  return ercTokenOwner[_tokenId];

  }

  function getApproved(uint256 _tokenId)override external view returns(address){

  return ercTokenApproved[_tokenId];

  }

  function isApprovedForAll(address _owner,address _operator)external view returns(bool){

  return ercOperatorForAll[_owner][_operator];

  }

  function approve(address _approved,uint256 _tokenId)override external payable{

  ercTokenApproved[_tokenId]=_approved;

  emit Approval(msg.sender,_approved,_tokenId);

  }

  function setApprovalForAll(address _operator,bool _approved)override external{

  ercOperatorForAll[msg.sender][_operator]=_approved;

  emit ApprovalForAll(msg.sender,_operator,_approved);

  }

  function transferFrom(address _from,address _to,uint256 _tokenId)override external payable{

  _transferFrom(_from,_to,_tokenId);

  }

  function _transferFrom(address _from,address _to,uint256 _tokenId)internal canTransfer(_tokenId,_from){

  ercTokenOwner[_tokenId]=_to;

  ercTokenCount[_to]+=1;

  ercTokenApproved[_tokenId]=address(0);

  emit Transfer(_from,_to,_tokenId);

  }

  function safeTransferFrom(address _from,address _to,uint256 _tokenId,bytes memory data)override external payable{

  _safeTransferFrom(_from,_to,_tokenId,data);

  }

  function safeTransferFrom(address _from,address _to,uint256 _tokenId)override external payable{

  _safeTransferFrom(_from,_to,_tokenId,"");

  }

  function _safeTransferFrom(address _from,address _to,uint256 _tokenId,bytes memory data)internal{

  _transferFrom(_from,_to,_tokenId);

  //add safe code

  if(_to.isContract()){//首先判断对方是否是合约

  bytes4 retval=ERC721TokenReceiver(_to).onERC721Received(msg.sender,_from,_tokenId,data);

  require(retval==ERC721TokenReceiver.onERC721Received.selector);

  }

  }

  function mint(address _to,uint256 _tokenId,bytes memory data)external{

  require(_to!=address(0));

  require(ercTokenOwner[_tokenId]==address(0));

  ercTokenOwner[_tokenId]=_to;

  ercTokenCount[_to]+=1;

  if(_to.isContract()){//首先判断对方是否是合约

  bytes4 retval=ERC721TokenReceiver(_to).onERC721Received(msg.sender,address(0),_tokenId,data);//是否实现了ERC721Received

  require(retval==ERC721TokenReceiver.onERC721Received.selector);

  }

  emit Transfer(address(0),_to,_tokenId);

  }

相关文章
|
SQL 安全 网络安全
交易所开发测试版丨交易所系统开发规则玩法/架构设计/项目步骤/方案逻辑/案例解析/源码部署
The development process of the exchange system involves multiple steps and links. The following is the detailed process and steps for the development of the exchange system:
|
7月前
|
缓存 前端开发 测试技术
什么是七星创客系统丨七星创客系统开发规则玩法/设计方案/逻辑需求/案例项目/源码功能
七星创客系统开发指南是一个帮助开发人员理解并完成七星创客系统的开发任务的指南。以下是一个简要的开发指南需求:
|
7月前
|
开发框架 缓存 监控
美丽天天秒丨链动2+1模式系统开发规则流程/功能设计/需求方案/成熟案例/源码指南
开发美丽天天秒丨链动2+1系统的流程可以按照以下步骤进行:
|
9月前
|
安全
什么是短剧系统开发/需求设计/逻辑方案/项目指南
The short drama system development plan refers to the development of a system for organizing and managing the process of short drama production, release, and playback.
|
9月前
|
安全
外汇交易所系统开发规则玩法/步骤逻辑/方案项目/教程指南/源码流程
The development of foreign exchange system involves a series of functions and features, aiming to provide a safe, efficient, transparent, and reliable trading platform for foreign exchange trading. The following are the functions that may be involved in the development of the foreign exchange exchan
|
9月前
|
自然语言处理 监控 搜索推荐
佛萨奇2.0/3.0Metaforce原力元宇宙系统开发步骤逻辑丨方案项目丨案例设计丨成熟技术丨源码功能
佛萨奇(VoZaChi)是一个虚拟助手系统,其发展至2.0和3.0版本会有一些特定需求和逻辑
|
监控 安全 数据挖掘
泰山众筹系统开发详细指南丨设计方案丨规则玩法丨逻辑功能丨步骤需求丨源码程序
泰山众筹系统是一个基于区块链技术的众筹平台,旨在为用户提供一个安全、透明和高效的众筹环境。
|
存储 安全 前端开发
DApp公排互助预约抢单排单模式系统开发参考版/详细流程/方案逻辑/规则玩法/案例设计/源码程序
需求分析:与团队明确系统的需求、目标和范围,包括公排互助预约抢单排单模式系统的功能、规则、奖励机制等方面
|
AndFix vr&ar 图形学
潮玩元宇宙/大逃杀游戏系统开发详细案例丨规则流程丨方案逻辑丨功能设计丨需求项目丨源码出售
The development of Chaoyu Metaverse Escape Game System refers to the creation and construction of a virtual reality game system to provide an immersive gaming experience, allowing players to participate in a virtual world for escape and combat.
|
存储 安全
DAPP/3M互助拆分公排双轨系统开发详细逻辑/案例分析/方案项目/技术分析/源码平台
 DApp是指基于区块练技术的去中心化应用程序,它的特点是去中心化、透明、安全、不可篡改等特点。