3M/MMM互助智能合约开发详情版,MMM/3M互助智能合约系统开发(说明及案例)丨源码部署

简介:   狭义来讲,区块链是一种按照时间顺序将数据区块以顺序相连的方式组合成的一种链式数据结构,并以密码学方式保证的不可篡改和不可伪造的分布式账本。

  

  区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。

  狭义来讲,区块链是一种按照时间顺序将数据区块以顺序相连的方式组合成的一种链式数据结构,并以密码学方式保证的不可篡改和不可伪造的分布式账本。

  广义来讲,区块链技术是利用块链式数据结构来验证与存储数据、利用分布式节点共识算法来生成和更新数据、利用密码学的方式保证数据传输和访问的安全、利用由自动化脚本代码组成的智能合约来编程和操作数据的一种全新的分布式基础架构与计算方式。

  在区块链技术中的数据有一定的顺序性, 每个数据区块都有一个“哈希值”代码,在链状数据结构中,任意区块中的数据改变都会影响后续与之相关所有区块的信息变化。这一技术确保区块链上的每个区块数据都不能随意被篡改、删除或破坏。因此,区块链技术在保证电子档案完整、真实的基础上还具有较强的追溯性

  //SPDX-License-Identifier:MIT

  pragma solidity^0.8.0;

  import"openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";

  import"./IERC4907.sol";

  contract ERC4907 is ERC721URIStorage,IERC4907{

  struct UserInfo{

  address user;//address of user role

  uint64 expires;//unix timestamp,user expires

  }

  mapping(uint256=>UserInfo)internal _users;

  constructor(string memory name_,string memory symbol_)ERC721(name_,symbol_){}

  ///notice set the user and expires of a NFT

  ///dev The zero address indicates there is no user

  ///Throws iftokenIdis not valid NFT

  ///param user The new user of the NFT

  ///param expires UNIX timestamp,The new user could use the NFT before expires

  function setUser(

  uint256 tokenId,

  address user,

  uint64 expires

  )public virtual override{

  require(

  _isApprovedOrOwner(msg.sender,tokenId),

  "ERC721:transfer caller is not owner nor approved"

  );

  UserInfo storage info=_users[tokenId];

  info.user=user;

  info.expires=expires;

  emit UpdateUser(tokenId,user,expires);

  }

  ///notice Get the user address of an NFT

  ///dev The zero address indicates that there is no user or the user is expired

  ///param tokenId The NFT to get the user address for

  ///return The user address for this NFT

  function userOf(uint256 tokenId)

  public

  view

  virtual

  override

  returns(address)

  {

  if(uint256(_users[tokenId].expires)>=block.timestamp){

  return _users[tokenId].user;

  }else{

  return address(0);

  }

  }

  ///notice Get the user expires of an NFT

  ///dev The zero value indicates that there is no user

  ///param tokenId The NFT to get the user expires for

  ///return The user expires for this NFT

  function userExpires(uint256 tokenId)

  public

  view

  virtual

  override

  returns(uint256)

  {

  return _users[tokenId].expires;

  }

  ///dev See{IERC165-supportsInterface}.

  function supportsInterface(bytes4 interfaceId)

  public

  view

  virtual

  override

  returns(bool)

  {

  return

  interfaceId==type(IERC4907).interfaceId||

  super.supportsInterface(interfaceId);

  }

  function _beforeTokenTransfer(

  address from,

  address to,

  uint256 tokenId

  )internal virtual override{

  super._beforeTokenTransfer(from,to,tokenId);

  if(from!=to&&_users[tokenId].user!=address(0)){

  delete _users[tokenId];

  emit UpdateUser(tokenId,address(0),0);

  }

  }

  }

相关文章
|
6月前
|
安全 JavaScript 前端开发
质押理财dapp系统开发功能详细/步骤需求/方案项目/源码指南
The development of a pledge wealth management DApp system involves knowledge in various aspects such as blockchain technology, smart contracts, front-end development, and security. The following are the detailed steps for developing a pledge wealth management DApp system
|
区块链 数据安全/隐私保护 算法
DAPP互助公排系统开发|DAPP三三复制系统开发(模式)
Web3.0的主要特点是开放、隐私和去中心化。
|
区块链
dapp互助公排智能合约系统开发指南与规则
智能合约作为区块链技术应用最广泛的场景之一
|
数据管理 区块链
DAPP智能合约/泰山众筹/互助公排模式系统开发合约源代码详情
def tfs(contract, token_name, user_address, amount): # 检查用户是否有足够的代币 balance = contract.functions.balanceOf(token_name, user_address).call()
|
区块链 安全
dapp丨defi丨lp智能合约系统开发规则玩法/逻辑说明/项目案例/方案设计/源码程序
Single and dual currency pledge mining is an economic incentive mechanism based on cryptocurrency projects. Under this mechanism, participants can obtain mining rewards by pledging a single cryptocurrency or a pair of cryptocurrencies (dual currency) they hold.
|
存储 安全 区块链
IPPswap+NFTswap+OMNIswap智能合约项目系统开发方案项目及源码案例
  DApp是指基于区块练技术的去中心化应用程序,它的特点是去中心化、透明、安全、不可篡改等,DApp is an inevitable trend because it can solve problems such as centralization,data privacy,and security in traditional applications,while also achieving more fair,transparent,an
|
存储 人工智能 安全
Opsea NFT智能合约平台系统开发方案介绍/功能详解/源码说明/项目案例
  DAPP是去中心化应用程序(Decentralized Application),它是建立在区块练技术之上的应用程序,具有去中心化、开放性、透明性、安全性等特点,DAPP可以实现各种功能,例如数字货币钱包、去中心化交易所、去中心化社交网络等。O
|
区块链
3M互助智能合约开发稳定版丨3M互助智能合约系统开发(玩法规则)/成熟案例/源码功能/案例项目/方案设计
 Smart contract DApp is the core technology for decentralized applications(DApp)using blockchain technology.The so-called smart contract refers to a smart contract system that automatically executes computer programs written in the form of digital code,realizing the automatic execution and managemen
|
区块链 安全
DAPP智能合约去中心化系统开发详细方案/项目案例/规则玩法/源码程序
   DAPP is a decentralized application that is built on blockchain technology and has the characteristics of decentralization, openness, transparency, security, etc. DAPP can achieve various functions, such as digital currency wallets, decentralized exchanges, decentralized social networks, etc.
|
存储 安全 区块链
MMM排单互助智能合约开发系统部署技术
目前实现的方式根据存储区分有各种各样的模式,但是都离不开一个最底层的机制,就是使用delegatecall的特性去实现可升级的合约,达到合约可持续优化更改的效果
MMM排单互助智能合约开发系统部署技术
下一篇
无影云桌面