这是我第一次编写智能合约,所以我仍在努力了解这一切是如何工作的。我在Rinkeby测试网络上有一个智能合约,目前在部署并导入OpenSea(他们的"列出"页面(时,它可以按预期工作。
问题是,我必须在智能合约的构造函数中创建NFT,方法是调用_mint((方法,使它们显示在OpenSea根据我的智能合约地址生成的集合中。我只部署了测试智能合约,铸造了该系列的前10个NFT,正如我所料,这10个NFt出现在OpenSea上。然而,我想利用OpenSea的懒惰铸造能力来避免自己铸造收藏中每个NFT(有10000个(的汽油费。
有没有一种方法可以建立智能合约,通知OpenSea(可能还有其他交易所(我很懒,并在OpenSea中显示所有10000个NFT,而不必在合约中预先铸造每个NFT?
我知道人们可以开发自己的网站,其他人可以在那里铸造他们想购买的每一个NFT,以实现懒惰铸造,但我希望这些NFT在OpenSea中都是可见的和可购买的,而不需要正式铸造(懒惰铸造(。我在IPFS上有我所有的NFT和元数据,当我执行实际的薄荷操作时,一切似乎都连接得很好,所以我知道这很好。我只需要了解是否/如何设置我的智能合约来启用此功能。
这是我当前的智能合约,IPFS的URL被占位符取代:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
import "./ContextMixin.sol";
contract MyTestContract is ERC1155, IERC2981, Ownable, Pausable, ContextMixin {
using SafeMath for uint256;
string public name;
string public symbol;
uint256 public total_supply;
address private _recipient;
constructor() ERC1155("IPFS_URL_TO_JSON_FILES_GOES_HERE") {
name = "MY Collection Name Goes Here";
symbol = "TESTING";
total_supply = 10000;
_recipient = owner();
_mint(msg.sender, 1, 1, "");
_mint(msg.sender, 2, 1, "");
_mint(msg.sender, 3, 1, "");
_mint(msg.sender, 4, 1, "");
_mint(msg.sender, 5, 1, "");
_mint(msg.sender, 6, 1, "");
_mint(msg.sender, 7, 1, "");
_mint(msg.sender, 8, 1, "");
_mint(msg.sender, 9, 1, "");
_mint(msg.sender, 10, 1, "");
}
function setURI(string memory newuri) public onlyOwner {
_setURI(newuri);
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function mint(address account, uint256 id, uint256 amount, bytes memory data)
public
onlyOwner
{
_mint(account, id, amount, data);
}
function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
public
onlyOwner
{
_mintBatch(to, ids, amounts, data);
}
function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
internal
whenNotPaused
override
{
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
}
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) external view override returns (address receiver, uint256 royaltyAmount) {
return (_recipient, (_salePrice * 500) / 10000);
}
function _setRoyalties(address newRecipient) internal {
require(newRecipient != address(0), "Royalties: new recipient is the zero address");
_recipient = newRecipient;
}
function setRoyalties(address newRecipient) external onlyOwner {
_setRoyalties(newRecipient);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, IERC165) returns (bool) {
return (interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId));
}
/**
* Override isApprovedForAll to auto-approve OS's proxy contract
*/
function isApprovedForAll(
address _owner,
address _operator
) public override view returns (bool isOperator) {
// if OpenSea's ERC1155 Proxy Address is detected, auto-return true
if (_operator == address(0x207Fa8Df3a17D96Ca7EA4f2893fcdCb78a304101)) {
return true;
}
// otherwise, use the default ERC1155.isApprovedForAll()
return ERC1155.isApprovedForAll(_owner, _operator);
}
/**
* This is used instead of msg.sender as transactions won't be sent by the original token owner, but by OpenSea.
*/
function _msgSender() internal override view returns (address sender) {
return ContextMixin.msgSender();
}
// Update for collection-specific metadata.
function contractURI() public pure returns (string memory) {
return "CONTRACT_LEVEL_METADATA_URL_GOES_HERE";
}
}
如有任何帮助,我们将不胜感激。
不,目前还不可能。当有一个网站你去为自己制作NFT时,该网站会做以下事情:
- 您单击"铸造",然后NFT将在合同上铸造到您的帐户。当你去Opensea时,他们可以在你的账户上获取NFT,然后加载他们的数据
目前,如果没有与EOA或合同账户相关的数据,他们就无法获得数据。
基本上,NFT必须是某人的。当你有数据,但没有所有者时,它就不是别人的。
我认为您想要做的是显示一个"懒惰铸造的";NFT在其中一个市场,对吧?如果这是你需要的,也许这篇文章会对你有所帮助?你可以使用Rarible的API将你的懒惰铸造数据上传到Rarible,然后可以在他们的网站上查看和铸造NFT。我不确定Openseas是否也提供了一个API来做这件事。一旦NFT被铸造出来,我想它可以在公海或稀有动物中看到。