DAPP公排互助拆分系统开发详情原理丨DAPP拆分互助公排系统开发玩法功能/方案设计/案例分析/成熟技术/源码版

简介: The lifecycle of smart contracts can be summarized into six stages based on their operational mechanisms: negotiation, development, deployment, operation and maintenance, learning, and self destruction. The development stage includes contract testing before contract chaining, while the learning sta

The lifecycle of smart contracts can be summarized into six stages based on their operational mechanisms: negotiation, development, deployment, operation and maintenance, learning, and self destruction. The development stage includes contract testing before contract chaining, while the learning stage includes feedback on the operation of smart contracts and contract updates. It is the infrastructure model of smart contracts, which is composed of infrastructure layer, contract layer, operation and maintenance layer, intelligent layer, presentation layer, and application layer from bottom to top

Decentralized storage technology is a new type of storage technology that changes the traditional centralized storage technology by moving data from a single location to multiple locations, eliminating the responsibility of the central organization or server storing data, increasing security and effective data storage, and ensuring user data security.

The structure of decentralized storage technology is a decentralized node network, which uses distributed storage to store and protect data.

,

Infrastructure layer: encapsulates all the infrastructure that supports the implementation of smart contracts and their derivative applications, including distributed ledgers and their key technologies, development environments, and trusted data sources. The selection of these infrastructure will to some extent affect the design patterns and contract attributes of smart contracts

  (bool success,bytes memory returndata)=_to.call(abi.encodeWithSelector(
function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes memory _data) external returns(bytes4);
}

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;            //记录用户token count;
mapping(uint256=>address)ercTokenOwner;            //记录token的拥有者;
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[_from]-=1;
    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 { //安全转账即判断对方是否有资格持有ERCtoken,避免转错
    _transferFrom(_from, _to, _tokenId);

    //add safe code
    if(_to.isContract()){           //首先判断对方是否是合约
        bytes4 retval = ERC721TokenReceiver(_to).onERC721Received(msg.sender,_from,_tokenId,data);   //是否实现了ERC721Received
        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);
}
相关文章
|
机器学习/深度学习 人工智能 算法
|
Linux Shell Python
-bash: pip: command not found pip命令报错 解决方法(Centos版)
-bash: pip: command not found pip命令报错 解决方法(Centos版)
5071 0
|
监控 编译器 API
[笔记]Windows核心编程《二十二》注入DLL和拦截API(一)
[笔记]Windows核心编程《二十二》注入DLL和拦截API
937 0
|
JSON JavaScript 数据格式
Elementui Tree 树形控件删除子节点
Elementui Tree 树形控件删除子节点
679 1
|
7月前
|
存储 NoSQL 数据库
办公Agent的长期记忆设计:记住员工偏好(通知方式、常用模板)
本文揭秘如何为办公Agent设计靠谱的长期记忆系统:通过三层偏好模型(显式/隐式/场景化)、混合存储方案、智能更新遗忘机制及隐私保护设计,让Agent真正“记住你”——不再重复提问,主动适配习惯。不堆术语,只讲实战经验与避坑指南。(239字)
735 0
|
5月前
|
存储 弹性计算 分布式计算
阿里云服务器实例规格怎么选?通用型、计算型、内存型、通用算力型等热门实例选型参考
阿里云ECS提供通用型(g系列)、计算型(c系列)、内存型(r系列)、通用算力型(u实例)和大数据型(d系列)五大实例规格,满足不同业务需求。g系列资源均衡,适用于Web应用、数据库等大多数场景;c系列CPU性能强,适合HPC、游戏服务器;r系列内存配比高达1:8,专为Redis、SAP HANA等内存数据库设计;u实例性价比突出,适合中小企业官网及开发测试;d系列配备大容量本地NVMe盘,面向Hadoop、Spark等大数据处理。选型时需根据预装软件、计算/内存/网络需求及存储特性综合匹配,如负载均衡选c系列、缓存选r系列、大数据选d系列,确保性能与成本最优平衡。
|
5月前
|
机器学习/深度学习 编解码 监控
包裹计数目标检测数据集(约6000张单类别YOLO标注已划分)源码分享
本数据集含约6000张物流实景图像,专为包裹自动计数设计,聚焦密集堆叠、遮挡严重、尺度多变等难点,采用单类别YOLO格式标注并完成标准划分(train/val/test),开箱即用于YOLOv5/v8/v9等主流模型训练,助力智能仓储、快递分拣等场景高效落地。
|
6月前
|
存储 人工智能 安全
Capability Persistence:Agentic Engineering 缺失的能力记忆层
本文揭示AI Agent工程中长期被忽视的“能力记忆缺失”问题:每次代码评审(Review)产生的执行性信息(如“该Agent在安全逻辑上判断力偏差”)均被系统性丢弃,仅规范性信息被用于更新规则。据此提出两条公理,推导出填补缺口的双闭环架构——在既有知识路径(Knowledge Path)之外,新增能力路径(Capability Path),通过Registry(持久化存储)、Router(任务路由)与Adapter(反馈适配)实现Agent执行能力的跨会话记忆与优化。
|
9月前
|
人工智能 JavaScript API
Web 端人脸识别新标准:玩美移动基于 JS Camera Kit 的实时图像采集与 AI 逻辑集成
JS Camera Kit SDK 是一款面向Web端的AI视觉开发工具,封装WebRTC与人脸检测模型,支持开箱即用的人脸识别(Face Detection)、异步加载、事件驱动及多模式配置(如facereshape),助力快速实现虚拟试妆、身份核验等高质量交互体验。
360 4
|
8月前
|
传感器 人工智能 运维
AgentRAG三大核心能力:意图识别+任务规划+经验库问答
AgentRAG创新性融合ReAct Agent、知识库与Skill,以意图识别、任务规划、经验库问答三大能力,破解传统RAG答非所问、难解复杂问题、无法复用企业经验等痛点,让AI真正懂业务、可落地、易部署。(238字)
667 0

热门文章

最新文章