Web3.0通过将信息交互从屏幕转移到物理空间,改变了终端用户体验,因而也有称Web3.0为“空间网络(Spatial Web)”。
该“空间网络”包括空间交互层(利用智能眼镜或语音等实现实时信息交互)、数字信息层(借助传感和数字映射为每一个对象创建数字孪生)和物理层(通过感观了解和体验的世界)。
区块链作为一种新型的技术组合,综合了P2P网络、共识算法、非对称加密、智能合约等新型技术,是一种在对等网络(也称分布式网络、点对点网络)环境下,通过透明和可信的规则,构建可追溯的块链式数据结构,具有分布式对等、链式数据块、防伪造和防篡改、可追溯、透明可信和高可靠性的典型特征
DAPP是去中心化应用程序/分布式的应用程序,是底层区块链平台生态上衍生的各种分布式应用,也是区块链世界中的基础服务提供方。
将应用程序分布在不同节点上,通过共识机制和区块链平台来完成任务的应用程序,它本身就是去中心化,不依赖于任何中心化服务器,促使用户交易更加安全。
truffle init rentable-nft
cd rentable-nft
truffle create contract RentablePets
truffle create contract IERC4907
truffle create contract ERC4907
truffle create test TestRentablePets
rentable-nft
├──contracts
│├──ERC4907.sol
│├──IERC4907.sol
│└──RentablePets.sol
├──migrations
│└──1_deploy_contracts.js
├──test
│└──test_rentable_pets.js
└──truffle-config.js
//SPDX-License-Identifier:MIT
pragma solidity>=0.4.22<0.9.0;
interface IERC4907{
//Logged when the user of a NFT is changed or expires is changed
///notice Emitted when theuser
of an NFT or theexpires
of theuser
is changed
///The zero address for user indicates that there is no user address
event UpdateUser(uint256 indexed tokenId,address indexed user,uint64 expires);
///notice set the user and expires of a NFT
///dev The zero address indicates there is no user
///Throws iftokenId
is 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)external;
///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)external view returns(address);
///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)external view returns(uint256);
}