IPPswap孵化器算力质押挖矿分红系统开发运营版/详细规则/源码部署

简介:   IPPswap孵化器将继续致力于数字资产交易市场的发展和创新。首先,该平台将进一步完善自身的技术体系和服务内容,推出更加多元化和优质的数字资产交易产品。

  IPPswap孵化器将继续致力于数字资产交易市场的发展和创新。首先,该平台将进一步完善自身的技术体系和服务内容,推出更加多元化和优质的数字资产交易产品。

  ,IPPswap孵化器支持多链和跨链功能。为了扩大数字资产交易市场的范围和灵活性,IPPswap孵化器通过跨链技术实现了不同公链之间的资产交换,同时支持多种数字资产的交易。

  pragma solidity^0.8.0;

  import"./IERC721.sol";

  import"./IERC721Receiver.sol";

  import"./extensions/IERC721Metadata.sol";

  import"../../utils/Address.sol";

  import"../../utils/Context.sol";

  import"../../utils/Strings.sol";

  import"../../utils/introspection/ERC165.sol";

  contract ERC721 is Context,ERC165,IERC721,IERC721Metadata{

  using Address for address;

  using Strings for uint256;

  //代币名称

  string private _name;

  //代币缩写

  string private _symbol;

  //token ID-->owner address

  mapping(uint256=>address)private _owners;

  //owner address-->token count

  mapping(address=>uint256)private _balances;

  //token ID-->approved address

  mapping(uint256=>address)private _tokenApprovals;

  //owner address-->operator approvals

  mapping(address=>mapping(address=>bool))private _operatorApprovals;

  //初始化token,设置name和symbol

  constructor(string memory name_,string memory symbol_){

  _name=name_;

  _symbol=symbol_;

  }

  //判断合约是否实现了接口id为interfaceId的接口

  function supportsInterface(bytes4 interfaceId)public view virtual override(ERC165,IERC165)returns(bool){

  return

  interfaceId==type(IERC721).interfaceId||

  interfaceId==type(IERC721Metadata).interfaceId||

  super.supportsInterface(interfaceId);

  }

  //返回owner拥有的代币总数量

  function balanceOf(address owner)public view virtual override returns(uint256){

  require(owner!=address(0),"ERC721:address zero is not a valid owner");

  return _balances[owner];

  }

  //传入token id,判断属于谁,返回一个地址

  function ownerOf(uint256 tokenId)public view virtual override returns(address){

  address owner=_owners[tokenId];

  require(owner!=address(0),"ERC721:invalid token ID");

  return owner;

  }

  //查看token名称

  function name()public view virtual override returns(string memory){

  return _name;

  }

  //查看token缩称

  function symbol()public view virtual override returns(string memory){

  return _symbol;

  }

  //传入token id,查看此id的详细信息,比如一个图片的URL

  function tokenURI(uint256 tokenId)public view virtual override returns(string memory){

  _requireMinted(tokenId);

  string memory baseURI=_baseURI();

  return bytes(baseURI).length>0?string(abi.encodePacked(baseURI,tokenId.toString())):"";

  }

  //是用于计算tokenURI的基础URI,默认为空

  function _baseURI()internal view virtual returns(string memory){

  return"";

  }

  //给出tokenId,调用者将其授权给to

  function approve(address to,uint256 tokenId)public virtual override{

  address owner=ERC721.ownerOf(tokenId);

  require(to!=owner,"ERC721:approval to current owner");

  require(

  _msgSender()==owner||isApprovedForAll(owner,_msgSender()),

  "ERC721:approve caller is not token owner nor approved for all"

  );

  _approve(to,tokenId);

  }

  //给出tokenId,判断其授权给谁了

  function getApproved(uint256 tokenId)public view virtual override returns(address){

  _requireMinted(tokenId);

  return _tokenApprovals[tokenId];

  }

  //调用者将自己的所有token授权给第三方operator(approved为true)false为取消授权

  function setApprovalForAll(address operator,bool approved)public virtual override{

  _setApprovalForAll(_msgSender(),operator,approved);

  }

  //判断owner是否把自己的所有token授权给operator了

  function isApprovedForAll(address owner,address operator)public view virtual override returns(bool){

  return _operatorApprovalsowner;

  }

  //from给to转移token

  function transferFrom(

  address from,

  address to,

  uint256 tokenId

  )public virtual override{

  //判断调用者是否被授权tokenId

  require(_isApprovedOrOwner(_msgSender(),tokenId),"ERC721:caller is not token owner nor approved");

  _transfer(from,to,tokenId);

  }

  //安全转移tokenId,两方地址不能为合约

  function safeTransferFrom(

  address from,

  address to,

  uint256 tokenId

  )public virtual override{

  safeTransferFrom(from,to,tokenId,"");

  }

  //安全转移tokenId,两方地址不能为合约,且带data数据

  function safeTransferFrom(

  address from,

  address to,

  uint256 tokenId,

  bytes memory data

  )public virtual override{

  require(_isApprovedOrOwner(_msgSender(),tokenId),"ERC721:caller is not token owner nor approved");

  _safeTransfer(from,to,tokenId,data);

  }

  //

  function _safeTransfer(

  address from,

  address to,

  uint256 tokenId,

  bytes memory data

  )internal virtual{

  _transfer(from,to,tokenId);

  require(_checkOnERC721Received(from,to,tokenId,data),"ERC721:transfer to non ERC721Receiver implementer");

  }

  //判断某个tokenId是否存在

  function _exists(uint256 tokenId)internal view virtual returns(bool){

  return _owners[tokenId]!=address(0);

  }

  //判断spender是否有权管理tokenId

  function _isApprovedOrOwner(address spender,uint256 tokenId)internal view virtual returns(bool){

  address owner=ERC721.ownerOf(tokenId);

  return(spender==owner||isApprovedForAll(owner,spender)||getApproved(tokenId)==spender);

  }

  //安全的铸造tokenId,并将其转移到to

  function _safeMint(address to,uint256 tokenId)internal virtual{

  _safeMint(to,tokenId,"");

  }

  //还是铸造tokenId,转移给to,多了个data

  function _safeMint(

  address to,

  uint256 tokenId,

  bytes memory data

  )internal virtual{

  _mint(to,tokenId);

  require(

  _checkOnERC721Received(address(0),to,tokenId,data),

  "ERC721:transfer to non ERC721Receiver implementer"

  );

  }

  //铸币的具体实现,一般不直接调用此方法,而是调用_safeMint

  function _mint(address to,uint256 tokenId)internal virtual{

  //转移的地址不能是0地址、新生成的tokenId不能已存在

  require(to!=address(0),"ERC721:mint to the zero address");

  require(!_exists(tokenId),"ERC721:token already minted");

  _beforeTokenTransfer(address(0),to,tokenId);

  //维护全局状态

  _balances[to]+=1;

  _owners[tokenId]=to;

  //触发转账事件

  emit Transfer(address(0),to,tokenId);

  _afterTokenTransfer(address(0),to,tokenId);

  }

  //销毁代币的具体实现

  function _burn(uint256 tokenId)internal virtual{

  address owner=ERC721.ownerOf(tokenId);

  _beforeTokenTransfer(owner,address(0),tokenId);

  //清理所有此tokenId的授权

  _approve(address(0),tokenId);

  //维护全局状态

  _balances[owner]-=1;

  delete _owners[tokenId];

  //触发转账事件,销毁就是转向0地址

  emit Transfer(owner,address(0),tokenId);

  _afterTokenTransfer(owner,address(0),tokenId);

  }

  //转账的具体实现

  function _transfer(

  address from,

  address to,

  uint256 tokenId

  )internal virtual{

  //tokenId需要属于from

  require(ERC721.ownerOf(tokenId)==from,"ERC721:transfer from incorrect owner");

  //转向的地址不能是0地址

  require(to!=address(0),"ERC721:transfer to the zero address");

  _beforeTokenTransfer(from,to,tokenId);

  //此tokenId转走时,清理掉之前的所有授权

  _approve(address(0),tokenId);

  //维护全局状态

  _balances[from]-=1;

  _balances[to]+=1;

  _owners[tokenId]=to;

  //触发转账事件

  emit Transfer(from,to,tokenId);

  _afterTokenTransfer(from,to,tokenId);

  }

  //授权的具体实现

  function _approve(address to,uint256 tokenId)internal virtual{

  _tokenApprovals[tokenId]=to;

  //触发授权事件

  emit Approval(ERC721.ownerOf(tokenId),to,tokenId);

  }

  //授权owner所有token的具体实现

  function _setApprovalForAll(

  address owner,

  address operator,

  bool approved

  )internal virtual{

  //授权的第三方不能是自己

  require(owner!=operator,"ERC721:approve to caller");

  _operatorApprovalsowner=approved;

  //触发全部授权事件

  emit ApprovalForAll(owner,operator,approved);

  }

  //如果此tokenId还不存在,重新去挖

  function _requireMinted(uint256 tokenId)internal view virtual{

  require(_exists(tokenId),"ERC721:invalid token ID");

  }

  //检查是否是合约地址等..

  function _checkOnERC721Received(

  address from,

  address to,

  uint256 tokenId,

  bytes memory data

  )private returns(bool){

  if(to.isContract()){

  try IERC721Receiver(to).onERC721Received(_msgSender(),from,tokenId,data)returns(bytes4 retval){

  return retval==IERC721Receiver.onERC721Received.selector;

  }catch(bytes memory reason){

  if(reason.length==0){

  revert("ERC721:transfer to non ERC721Receiver implementer");

  }else{

  /// solidity memory-safe-assembly

  assembly{

  revert(add(32,reason),mload(reason))

  }

  }

  }

  }else{

  return true;

  }

  }

  //

  function _beforeTokenTransfer(

  address from,

  address to,

  uint256 tokenId

  )internal virtual{}

  //

  function _afterTokenTransfer(

  address from,

  address to,

  uint256 tokenId

  )internal virtual{}

  }

相关文章
|
6月前
|
算法 区块链
DAPP算力质押分红系统开发|方案设计|需求细节
“去中心化”好像是最近一个热门的“新词汇”,相信关注区块链领域的朋友会经常听到这么一个词。
|
6月前
|
存储 算法 安全
DAPP算力质押生息系统开发|技术方案
区块链技术是一种去中心化的分布式账本技术,其本质是通过加密
|
区块链
DAPP/PPSWAP算力挖矿孵化器质押挖矿系统开发技术详情
IPPSWAP是一个去中心化的质押挖矿平台,支持用户使用各种数字货币进行质押,获得相应的代币奖励
|
安全 5G 区块链
IPPSWAP孵化器丨系统开发丨算力分红丨dapp质押挖矿系统开发案例及方案
IPPSWAP孵化器丨系统开发丨算力分红丨dapp质押挖矿系统开发案例及方案
|
开发框架 前端开发 安全
云算力质押挖矿系统开发(详细案例)丨云算力质押挖矿系统开发成熟技术/源码流程
云算力质押挖矿系统开发(详细案例)丨云算力质押挖矿系统开发成熟技术/源码流程
|
程序员 区块链
IPPswap孵化器合约算力系统开发|IPPswap孵化器模式系统开发(成熟技术)
智能合约可以实现去中心化的交易,消除了中间环节的干扰和风险
|
安全 分布式数据库 区块链
期权现货合约系统开发方案丨成熟技术
区块链本质上是一种去中心化的分布式数据库
|
区块链 数据安全/隐私保护
  DeFi借贷对冲功能开发部署
DeFi借贷对冲是指通过使用DeFi协议进行借贷,并使用对冲工具来降低借贷风险的方式。
|
区块链
SolaRoad (索拉迪)矿池算力分红开发运营版丨索拉迪SolaRoad智能合约系统开发详情介绍及源码说明
通俗地说,可以把区块链比作一种“账本”。传统账本由一方“集中记账”,这种新式“账本”则可以在互联网上由多方参与、共享,各参与方都可以“记账”并备份,而每个备份就是一个“区块”。
|
安全 区块链 数据安全/隐私保护
IPPSWAP孵化器丨DAPP智能合约丨算力分红丨系统开发方案及规则丨代码说明
 什么是智能合约?智能合约,又称加密合约,是在一定条件下可以直接控制数字资产或资产在各方之间转移的一种计算机程序z--Guts。智能合约不仅以与传统合约相同的方式定义了协议的规则和处罚,还可以自动强制执行这些义务。它通过接受信息作为输入,通过规则为输入赋值,在合约中列出并执行这些合约条款所要求的行为