ERC721 Contract Extensions – ERC721合同延期区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,ERC721 Contract Extensions – ERC721合同延期区块链毕设代写 是一篇很好的国外资料

ERC721 Contract Extensions

A set of composable extensions for the OpenZeppelin ERC721 base contracts.

Available Extensions

WithContractMetaData.sol

Link to your collection’s contract meta data right from within your smart contract.

Builds on Ownable and allows the contract owner to change contract metadata even after deployment.

Make sure the URL links to an appropriate JSON file.

contract Token is ERC721, WithContractMetadata {   constructor()     ERC721("Token", "LT")     WithContractMetadata("ipfs://0123456789123456789123456789123456789123456789/metadata.json")   {} }

To change the contract metadat URI, call setContractURI(string uri) as the contract owner.

WithIPFSMetaData.sol

Handles linking to metadata files hosted on IPFS and follows best practices doing so:

  • Projects have to embed the Content ID hash in the contract right from the start
  • Project owners can never change the CID
  • Tokens link to an ipfs://-URL to be independent of particular IPFS Gateways.
  • Tokens wrap a folder with a metadata.json file (and pot. all the assets of the token).

Note: You should never publish metadata before public sale is complete.
This is to prevent people from trying to snipe rare tokens (rarity can be derived from going through all metadata files and looking at the trait and attribute distributions). Although very expensive (in gas fees) to do so, it is potentially possible and thus bad practice.

contract CleanToken is ERC721, WithIPFSMetaData {   constructor()     ERC721("CleanToken", "CT")     WithIPFSMetaData("0123456789123456789123456789123456789123456789")   {} }

WithIPFSMetadataAndPreviewMetadata.sol

TODO

WithTransferTimeLock.sol

To prevent an attack vector right after public sale of tokens, this extension adds a timelock to transfers for 12 hours after initial sale. This gives all buyers enough time to familiarise themselves with their tokens and the entire collection, as well as the rarities of items.

Alternatively: Publish the entire collection without tokenIDs from the get go / or at least all rarity statistics.

TODO

WithLimitedSupply.sol

A simple token tracker that limits the token supply.

To keep track of the token supply and to get the next available tokenID, call nextToken() when creating new tokens.

contract RareToken is ERC721, WithLimitedSupply {   constructor()     ERC721("RareToken", "RT")     WithLimitedSupply(1000) // Max. 1k NFTs available   {}    function mint () external {     uint256 newTokenId = nextToken(); // Create a new token ID      // ...   } }

The internal nextToken() method automatically checks whether tokens are available via the ensureAvailability modifier. If you implement minting multiple tokens within the same transaction, you should check availability with the ensureAvailabilityFor(amount) helper.

There are two Contracts that build on this: LinearlyAssigned, which adds the option of starting the token tracker from a specific number and RandomlyAssigned, wich enables semi random token ID assignments.

LinearlyAssigned.sol

Instanciate it with the max supply as well as the starting index:

contract RareToken is ERC721, LinarlyAssigned {   constructor()     ERC721("RareToken", "RT")     LinarlyAssigned(1000, 1) // Max. 1k NFTs available; Start counting from 1 (instead of 0)   {}    function mint () external {     uint256 newTokenId = nextToken(); // Create a new token ID      // ...   } }

RandomlyAssigned.sol

(Semi-)randomly* assign token IDs from a fixed collection size on mint.

contract RandomToken is ERC721, RandomlyAssigned {   constructor()     ERC721("RandomToken", "RT")     RandomlyAssigned(1000, 1) // Max. 1k NFTs available; Start counting from 1 (instead of 0)   {}    function mint () external {     uint256 newTokenId = nextToken(); // Create a new random token ID      // ...   } }

*) We can’t create proper random numbers on chain. But this does the job well enough, if you hide your metadata during public sale and are not too valuable of an NFT project (pot. exploit costs a lot of gas, thus making it economically unfeasible to do for profit for ‘normal’ NFT collections). If you want true random assignment, check out Chainlink.

WithSaleStart.sol

An extension that enables the contract owner to set and update the date of a public sale.

This builds upon the Ownable extension, so only contract deployers can change the sale start via setSaleStart(uint256 time). Also, to stay true to the trustless spirit of NFTs, it is not possible to change the sale start after the initial sale started.

To use this in your project, call the afterSaleStart / beforeSaleStart modifiers.

contract MyToken is ERC721, WithSaleStart {   constructor()     ERC721("MyToken", "MT")     WithSaleStart(1735686000)   {}    function claim () external afterSaleStart {     // ...   } }

LimitedTokensPerWallet.sol

Limits the amount of tokens an external wallet can hold.

contract LimitedToken is ERC721, LimitedTokensPerWallet {   constructor()     ERC721("LimitedToken", "LT")     LimitedTokensPerWallet(3) // Only allow three tokens per wallet   {}    // Mint & Transfer limits are taken care of by the library. }

OnePerWallet.sol

A more extreme version of LimitedTokensPerWallet, which only allows holding one token in an external wallet address.

To use this in your project just extend the Contract. If you need more control, call the onePerWallet modifier.

contract OneForAllToken is ERC721, OnePerWallet {   constructor()     ERC721("OneForAllToken", "OFA")   {}    // Mints and Transfer limites are taken care of by the library. }

WithMarketOffers.sol

Implements a simple offer based marketplace. Owners of tokens can choose to sell them via the in-built market.

Just extend the WithMarketOffers.sol contract to make this work.

WithFees.sol

Aims to abstracts out the complexity of current fee standards.

contract SharedUpsideToken is ERC721, WithFees {   constructor()     ERC721("SharedUpsideToken", "SUP")     // 500 Basis Points (5%) of secondary sales      // should go to the given beneficiary address     WithFees(0xe11Da9560b51f8918295edC5ab9c0a90E9ADa20B, 500)   {}    function supportsInterface(bytes4 interfaceId) public view override(WithFees, ERC721) returns (bool) {     return WithFees.supportsInterface(interfaceId);   } }

WithWithdrawals.sol

A simple helper that implements a withdrawal function.

Just call withdraw as the contract owner.

Installation

  1. In your project run npm install @1001-digital/erc721-exensions
  2. Within your project, import the extensions you want to use like import "@1001-digital/erc721-exensions/contracts/WithIPFSMetaData.sol";

Local Development

This project uses the Hardhat development environment. To set it up locally, clone this repository and run npm install.

Note: You can exchange npm run for hh if you have hh installed globally on your system.

  • Run the test suite: npm run test
  • Spin up a local development blockchain: npm run node

Thank You

If you have any improvement suggestions, feedback or bug reports please feel free add an issue, or reach out via Twitter @jwahdatehagh or Email [email protected]


ERC721合同延期

OpenZeppelin ERC721基本合同的一组可组合扩展

可用延期

带合同元数据.sol

从智能合约中直接链接到收藏的合约元数据

构建在可拥有的基础上,允许合同所有者即使在部署后也更改合同元数据

确保URL链接到适当的JSON文件

contract Token is ERC721, WithContractMetadata {   constructor()     ERC721("Token", "LT")     WithContractMetadata("ipfs://0123456789123456789123456789123456789123456789/metadata.json")   {} }

若要更改合同metadat URI,请将setContractURI(字符串URI)作为合同所有者调用

和PreviewMetadata.sol

处理到托管在IPFS上的元数据文件的链接,并遵循这样做的最佳实践:

  • 项目必须从一开始就在合同中嵌入内容ID哈希
  • 项目所有者永远不能将CID
  • 令牌链接更改为ipfs://-URL 独立于特定IPFS网关
  • 令牌用metadata.json文件(和pot)包装文件夹。令牌的所有资产)

注意:在公开销售完成之前,您不应该发布元数据。
这是为了防止人们试图窃听稀有标记(稀有性可以通过查看所有元数据文件并查看特征和属性来获得)分配)。尽管这样做非常昂贵(汽油费),但这是可能的,因此是不好的做法

contract CleanToken is ERC721, WithIPFSMetaData {   constructor()     ERC721("CleanToken", "CT")     WithIPFSMetaData("0123456789123456789123456789123456789123456789")   {} }

使用Salestart.sol

LimitedTokensparlet.sol

OnePerWallet.sol

with MarketOffers.sol

with Fees.sol

with Drawals.sol

安装

本地开发

谢谢您

  • 项目必须从一开始就在合同中嵌入内容ID哈希
  • 项目所有者永远不能将CID
  • 令牌链接更改为ipfs://-URL 独立于特定IPFS网关
  • 令牌用metadata.json文件(和pot)包装文件夹。令牌的所有资产)
  • 在您的项目中运行npm [email protected] digital/erc721 exensions
  • 在您的项目中,导入要使用的扩展,如导入“@1001 digital/erc721 exensions/contracts/WithIPFSMetaData.sol”
  • 运行测试套件:npm运行测试
  • 启动本地开发区块链blockchain:npm运行节点
  • 或者:发布整个集合,而不使用get go中的TokenID/或至少所有稀有性统计信息

    使用Salestart.sol

    LimitedTokensparlet.sol

    OnePerWallet.sol

    with MarketOffers.sol

    with Fees.sol

    with Drawals.sol

    安装

    本地开发

    谢谢您

  • 项目必须从一开始就在合同中嵌入内容ID哈希
  • 项目所有者永远不能将CID
  • 令牌链接更改为ipfs://-URL 独立于特定IPFS网关
  • 令牌用metadata.json文件(和pot)包装文件夹。令牌的所有资产)
  • 在您的项目中运行npm [email protected] digital/erc721 exensions
  • 在您的项目中,导入要使用的扩展,如导入“@1001 digital/erc721 exensions/contracts/WithIPFSMetaData.sol”
  • 运行测试套件:npm运行测试
  • 启动本地开发区块链blockchain:npm运行节点
  • TODO

    限制令牌供应的简单令牌跟踪器

    要跟踪令牌供应并获取下一个可用的令牌ID,请在创建新令牌时调用nextToken()

    LimitedTokensparlet.sol

    OnePerWallet.sol

    with MarketOffers.sol

    with Fees.sol

    with Drawals.sol

    安装

    本地开发

    谢谢您

  • 项目必须从一开始就在合同中嵌入内容ID哈希
  • 项目所有者永远不能将CID
  • 令牌链接更改为ipfs://-URL 独立于特定IPFS网关
  • 令牌用metadata.json文件(和pot)包装文件夹。令牌的所有资产)
  • 在您的项目中运行npm [email protected] digital/erc721 exensions
  • 在您的项目中,导入要使用的扩展,如导入“@1001 digital/erc721 exensions/contracts/WithIPFSMetaData.sol”
  • 运行测试套件:npm运行测试
  • 启动本地开发区块链blockchain:npm运行节点
  • internal nextToken()方法自动检查令牌是否可通过ensureAvailability修饰符使用。如果在同一事务中实现多个代币的铸造,则应与(金额)帮助器的InsureAvailabilityFor(amount)检查可用性

    在此基础上有两个契约:LinearlyAssigned,它添加了从特定数字启动令牌跟踪器的选项,并随机分配,从而启用半随机令牌ID分配

    contract RareToken is ERC721, WithLimitedSupply {   constructor()     ERC721("RareToken", "RT")     WithLimitedSupply(1000) // Max. 1k NFTs available   {}    function mint () external {     uint256 newTokenId = nextToken(); // Create a new token ID      // ...   } }

    将其与最大供应量以及起始索引关联:

    (半)随机*从mint上的固定集合大小分配令牌ID

    LimitedTokensparlet.sol

    OnePerWallet.sol

    with MarketOffers.sol

    with Fees.sol

    with Drawals.sol

    安装

    本地开发

    谢谢您

  • 项目必须从一开始就在合同中嵌入内容ID哈希
  • 项目所有者永远不能将CID
  • 令牌链接更改为ipfs://-URL 独立于特定IPFS网关
  • 令牌用metadata.json文件(和pot)包装文件夹。令牌的所有资产)
  • 在您的项目中运行npm [email protected] digital/erc721 exensions
  • 在您的项目中,导入要使用的扩展,如导入“@1001 digital/erc721 exensions/contracts/WithIPFSMetaData.sol”
  • 运行测试套件:npm运行测试
  • 启动本地开发区块链blockchain:npm运行节点
  • *)我们无法在链上创建正确的随机数。但是,如果您在公开销售期间隐藏元数据,并且对NFT项目(pot)没有太大价值,那么这就足够了。开采成本很高,因此在经济上不可能实现“正常”NFT收集的利润)。如果您想要真正的随机分配,请查看Chainlink

    contract RareToken is ERC721, LinarlyAssigned {   constructor()     ERC721("RareToken", "RT")     LinarlyAssigned(1000, 1) // Max. 1k NFTs available; Start counting from 1 (instead of 0)   {}    function mint () external {     uint256 newTokenId = nextToken(); // Create a new token ID      // ...   } }

    OnePerWallet.sol

    with MarketOffers.sol

    with Fees.sol

    with Drawals.sol

    安装

    本地开发

    谢谢您

  • 项目必须从一开始就在合同中嵌入内容ID哈希
  • 项目所有者永远不能将CID
  • 令牌链接更改为ipfs://-URL 独立于特定IPFS网关
  • 令牌用metadata.json文件(和pot)包装文件夹。令牌的所有资产)
  • 在您的项目中运行npm [email protected] digital/erc721 exensions
  • 在您的项目中,导入要使用的扩展,如导入“@1001 digital/erc721 exensions/contracts/WithIPFSMetaData.sol”
  • 运行测试套件:npm运行测试
  • 启动本地开发区块链blockchain:npm运行节点
  • 允许合同所有人设置和更新公开销售日期的扩展

    contract RandomToken is ERC721, RandomlyAssigned {   constructor()     ERC721("RandomToken", "RT")     RandomlyAssigned(1000, 1) // Max. 1k NFTs available; Start counting from 1 (instead of 0)   {}    function mint () external {     uint256 newTokenId = nextToken(); // Create a new random token ID      // ...   } }

    这建立在可拥有的扩展之上,因此只有合同部署人员可以通过setSaleStart(uint256时间)更改销售开始。此外,为了忠实于NFT的不可信任精神,不可能在初始销售开始后更改销售开始时间

    with MarketOffers.sol

    with Fees.sol

    with Drawals.sol

    安装

    本地开发

    谢谢您

  • 项目必须从一开始就在合同中嵌入内容ID哈希
  • 项目所有者永远不能将CID
  • 令牌链接更改为ipfs://-URL 独立于特定IPFS网关
  • 令牌用metadata.json文件(和pot)包装文件夹。令牌的所有资产)
  • 在您的项目中运行npm [email protected] digital/erc721 exensions
  • 在您的项目中,导入要使用的扩展,如导入“@1001 digital/erc721 exensions/contracts/WithIPFSMetaData.sol”
  • 运行测试套件:npm运行测试
  • 启动本地开发区块链blockchain:npm运行节点
  • 要在项目中使用此选项,请调用afterSaleStart/beforeSaleStart修饰符

    限制外部钱包可以持有的代币数量

    LimitedTokensPerWallet的更极端版本,它只允许在外部钱包地址中持有一个令牌

    contract MyToken is ERC721, WithSaleStart {   constructor()     ERC721("MyToken", "MT")     WithSaleStart(1735686000)   {}    function claim () external afterSaleStart {     // ...   } }

    with Fees.sol

    with Drawals.sol

    安装

    本地开发

    谢谢您

  • 项目必须从一开始就在合同中嵌入内容ID哈希
  • 项目所有者永远不能将CID
  • 令牌链接更改为ipfs://-URL 独立于特定IPFS网关
  • 令牌用metadata.json文件(和pot)包装文件夹。令牌的所有资产)
  • 在您的项目中运行npm [email protected] digital/erc721 exensions
  • 在您的项目中,导入要使用的扩展,如导入“@1001 digital/erc721 exensions/contracts/WithIPFSMetaData.sol”
  • 运行测试套件:npm运行测试
  • 启动本地开发区块链blockchain:npm运行节点
  • 要在项目中使用此功能,只需延长合同即可。如果需要更多控制,请致电onePerWallet修改器

    contract LimitedToken is ERC721, LimitedTokensPerWallet {   constructor()     ERC721("LimitedToken", "LT")     LimitedTokensPerWallet(3) // Only allow three tokens per wallet   {}    // Mint & Transfer limits are taken care of by the library. }

    with Fees.sol

    with Drawals.sol

    安装

    本地开发

    谢谢您

  • 项目必须从一开始就在合同中嵌入内容ID哈希
  • 项目所有者永远不能将CID
  • 令牌链接更改为ipfs://-URL 独立于特定IPFS网关
  • 令牌用metadata.json文件(和pot)包装文件夹。令牌的所有资产)
  • 在您的项目中运行npm [email protected] digital/erc721 exensions
  • 在您的项目中,导入要使用的扩展,如导入“@1001 digital/erc721 exensions/contracts/WithIPFSMetaData.sol”
  • 运行测试套件:npm运行测试
  • 启动本地开发区块链blockchain:npm运行节点
  • 实现一个简单的基于报价的市场。代币的所有者可以选择通过内置市场出售代币

    只要扩展WithMarketOffers.sol合同就可以了

    contract OneForAllToken is ERC721, OnePerWallet {   constructor()     ERC721("OneForAllToken", "OFA")   {}    // Mints and Transfer limites are taken care of by the library. }

    with Drawals.sol

    旨在抽象出当前收费标准的复杂性

    实现提取功能的简单助手

    安装

    本地开发

    谢谢您

  • 项目必须从一开始就在合同中嵌入内容ID哈希
  • 项目所有者永远不能将CID
  • 令牌链接更改为ipfs://-URL 独立于特定IPFS网关
  • 令牌用metadata.json文件(和pot)包装文件夹。令牌的所有资产)
  • 在您的项目中运行npm [email protected] digital/erc721 exensions
  • 在您的项目中,导入要使用的扩展,如导入“@1001 digital/erc721 exensions/contracts/WithIPFSMetaData.sol”
  • 运行测试套件:npm运行测试
  • 启动本地开发区块链blockchain:npm运行节点
  • 只需以合同所有者的身份调用Draw即可

    contract SharedUpsideToken is ERC721, WithFees {   constructor()     ERC721("SharedUpsideToken", "SUP")     // 500 Basis Points (5%) of secondary sales      // should go to the given beneficiary address     WithFees(0xe11Da9560b51f8918295edC5ab9c0a90E9ADa20B, 500)   {}    function supportsInterface(bytes4 interfaceId) public view override(WithFees, ERC721) returns (bool) {     return WithFees.supportsInterface(interfaceId);   } }

    本地开发

    谢谢您

  • 项目必须从一开始就在合同中嵌入内容ID哈希
  • 项目所有者永远不能将CID
  • 令牌链接更改为ipfs://-URL 独立于特定IPFS网关
  • 令牌用metadata.json文件(和pot)包装文件夹。令牌的所有资产)
  • 在您的项目中运行npm [email protected] digital/erc721 exensions
  • 在您的项目中,导入要使用的扩展,如导入“@1001 digital/erc721 exensions/contracts/WithIPFSMetaData.sol”
  • 运行测试套件:npm运行测试
  • 启动本地开发区块链blockchain:npm运行节点
  • 此项目使用Hardhat开发环境。要在本地进行设置,请克隆此存储库并运行npm安装

    注意:如果系统中全局安装了hh,则可以将npm run替换为hh

    本地开发

    谢谢您

  • 项目必须从一开始就在合同中嵌入内容ID哈希
  • 项目所有者永远不能将CID
  • 令牌链接更改为ipfs://-URL 独立于特定IPFS网关
  • 令牌用metadata.json文件(和pot)包装文件夹。令牌的所有资产)
  • 在您的项目中运行npm [email protected] digital/erc721 exensions
  • 在您的项目中,导入要使用的扩展,如导入“@1001 digital/erc721 exensions/contracts/WithIPFSMetaData.sol”
  • 运行测试套件:npm运行测试
  • 启动本地开发区块链blockchain:npm运行节点
    1. 在您的项目中运行npm [email protected] digital/erc721 exensions
    2. 在您的项目中,导入要使用的扩展,如导入“@1001 digital/erc721 exensions/contracts/WithIPFSMetaData.sol”

    谢谢您

  • 项目必须从一开始就在合同中嵌入内容ID哈希
  • 项目所有者永远不能将CID
  • 令牌链接更改为ipfs://-URL 独立于特定IPFS网关
  • 令牌用metadata.json文件(和pot)包装文件夹。令牌的所有资产)
  • 在您的项目中运行npm [email protected] digital/erc721 exensions
  • 在您的项目中,导入要使用的扩展,如导入“@1001 digital/erc721 exensions/contracts/WithIPFSMetaData.sol”
  • 运行测试套件:npm运行测试
  • 启动本地开发区块链blockchain:npm运行节点
  • 如果您有任何改进建议、反馈或bug报告,请随时添加问题,或通过[email protected]或电子邮件联系[email protected]

    Note: You can exchange npm run for hh if you have hh installed globally on your system.

    谢谢您

  • 项目必须从一开始就在合同中嵌入内容ID哈希
  • 项目所有者永远不能将CID
  • 令牌链接更改为ipfs://-URL 独立于特定IPFS网关
  • 令牌用metadata.json文件(和pot)包装文件夹。令牌的所有资产)
  • 在您的项目中运行npm [email protected] digital/erc721 exensions
  • 在您的项目中,导入要使用的扩展,如导入“@1001 digital/erc721 exensions/contracts/WithIPFSMetaData.sol”
  • 运行测试套件:npm运行测试
  • 启动本地开发区块链blockchain:npm运行节点
  • If you have any improvement suggestions, feedback or bug reports please feel free add an issue, or reach out via Twitter @jwahdatehagh or Email [email protected]

    部分转自网络,侵权联系删除区块链源码网

    www.interchains.cc

    https://www.interchains.cc/24030.html

    区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
    区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » ERC721 Contract Extensions – ERC721合同延期区块链毕设代写

    提供最优质的资源集合

    立即查看 了解详情