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

简介: 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);

  }

相关文章
|
5月前
|
缓存 前端开发 测试技术
什么是七星创客系统丨七星创客系统开发规则玩法/设计方案/逻辑需求/案例项目/源码功能
七星创客系统开发指南是一个帮助开发人员理解并完成七星创客系统的开发任务的指南。以下是一个简要的开发指南需求:
|
5月前
|
开发框架 缓存 监控
美丽天天秒丨链动2+1模式系统开发规则流程/功能设计/需求方案/成熟案例/源码指南
开发美丽天天秒丨链动2+1系统的流程可以按照以下步骤进行:
|
7月前
|
安全
什么是短剧系统开发/需求设计/逻辑方案/项目指南
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.
|
前端开发 区块链 数据库
单双币质押拆分理财系统DAPP开发搭建部署规则设计
单双币质押拆分理财系统DAPP开发搭建部署规则设计
|
7月前
|
新零售 人工智能 搜索推荐
2+1链动互助模式系统开发|项目方案|流程分析
对于消费者而言,我们已经习惯了便捷的网络购物方式,但是网购我们无法了解商品的质量,
|
存储 前端开发 安全
dapp矩阵公排互助预约排单抢单项目系统开发指南流程丨案例设计丨功能逻辑丨规则玩法丨项目方案丨源码程序
需求分析:与团队明确系统的需求和目标,包括公排互助预约排单抢单项目系统的功能、规则、奖励机制等方面。
|
存储 安全 前端开发
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是指基于区块练技术的去中心化应用程序,它的特点是去中心化、透明、安全、不可篡改等特点。
|
存储 分布式数据库 区块链
DAPP竞拍互助拆分公排系统开发玩法规则/详细逻辑/源码程序
  区块链技术一般用于构建交易系统,而且要保证交易的信息真实可信,可追踪且不可篡改。每一次交易的信息被确认后存储在一个区块中,区块信息通过散列技术加密,以保证信息不被篡改。这些区块按时间顺序构成链条。每个节点都保有完整的区块链信息,个别节点的信息损坏,不会对区块链信息产生影响。这种信息记录方式被称作分布式账本。