DAPP公排拆分互助模式系统开发方案实现,3M/DAPP拆分公排互助系统开发详细规则(开发项目)及源码

简介:  Blockchain technology can build an efficient and reliable value transmission system, promote the Internet to become a network infrastructure for building social trust, achieve effective transmission of value, and call this the Value Internet. Blockchain provides a new type of social trust mechanis

Blockchain technology can build an efficient and reliable value transmission system, promote the Internet to become a network infrastructure for building social trust, achieve effective transmission of value, and call this the Value Internet. Blockchain provides a new type of social trust mechanism, laying a new foundation for the development of the digital economy. The innovation of "blockchain+" application indicators a new direction for industrial innovation and public services

What is blockchain? In a word, it is a special Distributed database. Firstly, the main function of blockchain is to store information. Any information that needs to be saved can be written to or read from the blockchain, so it is a database.

Blockchain technology, also known as distributed ledger technology, is an internet database technology characterized by decentralization, openness, and transparency, allowing everyone to participate in database records. Blockchain technology is not a single technology, but a comprehensive technology system that integrates multiple research achievements

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.7;

import "./IERC165.sol";
import "./IERC721.sol";
import "./Address.sol"; //导入库

/// @dev Note: the ERC-165 identifier for this interface is 0x150b7a02.
interface ERC721TokenReceiver {
/// @notice Handle the receipt of an NFT
/// @dev The ERC721 smart contract calls this function on the recipient
/// after a transfer. This function MAY throw to revert and reject the
/// transfer. Return of other than the magic value MUST result in the
/// transaction being reverted.
/// Note: the contract address is always the message sender.
/// @param _operator The address which called safeTransferFrom function
/// @param _from The address which previously owned the token
/// @param _tokenId The NFT identifier which is being transferred
/// @param _data Additional data with no specified format
/// @return bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))
/// unless throwing
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);
}

}

相关文章
|
1月前
|
存储 安全 前端开发
DAPP循环矩阵互助公排系统开发模式规则技术
DAPP循环矩阵互助公排系统是一款基于区块链技术的去中心化应用,通过智能合约实现透明、自动化的互助众筹。系统涵盖用户注册、身份验证、项目发布与审核、资金管理等功能,并采用循环矩阵和公排机制激励用户参与。通过区块链和智能合约技术,确保资金安全和项目真实性,同时提供社区互动平台增强用户体验。系统开发需持续优化迭代,关注市场需求及法律合规,打造安全、透明、高效的互助平台。
|
4月前
|
安全
链游系统开发DAPP项目逻辑讲解方案
链游系统开发具有以下优势:   1.Decentralization:Chain game systems are based on blockchain technology and do not rely on centralized servers,providing a more fair and transparent gaming environment.   2.Data security:Through the decentralized characteristics and encryption algorithms of blockchain,the chai
|
4月前
|
人工智能 算法 安全
DAPP 合约拆分公排模式项目系统开发技术讲解
DAPp 互助模式系统的核心理念是“共创、共享、共赢”。通过整合优质资源,平台致力于为用户提供一个公平、公正、透明的互助环境。用户在这里可以实现信息的快速传播,从而为互助需求提供便捷的服务。
|
6月前
|
算法 区块链 UED
dapp矩阵公排互助系统开发|方案设计|模式案例
Web3.0的智能合约技术可以实现无需信任的推广活动
|
6月前
|
安全 区块链 UED
DAPP去中心化公排互助系统开发|详情逻辑|案例分析
智能合约是一种基于区块链技术的自动化执行合约的工具
|
区块链 数据安全/隐私保护 算法
DAPP互助公排系统开发|DAPP三三复制系统开发(模式)
Web3.0的主要特点是开放、隐私和去中心化。
|
安全 区块链
DAPP互助拆分公排系统开发(智能合约)
去中心化,不是不要中心,而是由节点来自由选择中心、自由决定中心。简单地说,中心化的意思,是中心决定节点。
|
存储 安全
DAPP/3M互助拆分公排双轨系统开发详细逻辑/案例分析/方案项目/技术分析/源码平台
 DApp是指基于区块练技术的去中心化应用程序,它的特点是去中心化、透明、安全、不可篡改等特点。
|
存储 算法 前端开发
区块链 DAPP 互助逻辑模式系统开发技术源码方案
string public name; uint public goal; uint public progress; address public admin; mapping (address => bool) public members;
|
存储 前端开发 测试技术
众筹互助智能合约系统开发(开发案例)丨dapp智能合约众筹互助丨公排拆分丨系统开发详细规则/成熟技术/方案设计/源码说明
 智能合约互助系统开发是指创建并实现基于智能合约技术的互助系统。智能合约是一种在区块链上执行的自动化计算代码,它可以在事先设定的条件满足时执行相应的操作,无需依赖人工干预。智能合约互助系统旨在通过智能合约技术来优化和自动化互助服务的提供和管理。