简体   繁体   English

如何修复“身份不明的合同”? OpenSea 无法“理解”ERC1155

[英]How to fix "Unidentified contract"? OpenSea is unable to “understand” ERC1155

I have deployed a ERC-1155 based contract (based on OpenZeppelin ) and minted some NFTs on this contract successfully.我已经部署了一个基于ERC-1155的合约(基于OpenZeppelin )并成功地在这个合约上铸造了一些 NFT。 But when I want to use these NFTs in OpenSea, it always says "Unidentified contract" .但是当我想在 OpenSea 中使用这些 NFT 时,它总是说“Unidentified contract”

Example: https://testnets.opensea.io/assets/0xc7d3e4a5A0c3e14ba8C68ea1b8a99a9dBf3ca76F/2示例: https ://testnets.opensea.io/assets/0xc7d3e4a5A0c3e14ba8C68ea1b8a99a9dBf3ca76F/2

API-Example: https://testnets-api.opensea.io/api/v1/asset/0xc7d3e4a5A0c3e14ba8C68ea1b8a99a9dBf3ca76F/2/?force_update=true API 示例: https ://testnets-api.opensea.io/api/v1/asset/0xc7d3e4a5A0c3e14ba8C68ea1b8a99a9dBf3ca76F/2/?force_update=true

Following their official Tutorial repository (which does not compile any more because of outdated dependencies and other issues) I have added some (maybe) opensea-specific functions and data that might required for OpenSea in order to work properly.在他们的官方教程存储库(由于过时的依赖项和其他问题而不再编译)之后,我添加了一些(可能)OpenSea 特定的函数和数据,这些函数和数据可能需要 OpenSea 才能正常工作。 However, OpenSea is able to grab all required data to display an NFT, but as long as they say "Unidentified contract", this all makes no sense so far.然而,OpenSea 能够获取显示 NFT 所需的所有数据,但只要他们说“Unidentified contract”,到目前为止这一切都没有意义。

My question has:我的问题是:

has someone already managed to deploy a ERC-1155 and used it with OpenSea properly without this issue?是否有人已经设法部署 ERC-1155 并将其与 OpenSea 一起正确使用而没有此问题? Is there anything we have to "register" somehow contracts that are not based on ERC-721?有什么我们必须以某种方式“注册”不基于 ERC-721 的合同吗?

🔢 Code to reproduce 🔢 重现代码

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol";

import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";


contract OwnableDelegateProxy { }

contract ProxyRegistry {
  mapping(address => OwnableDelegateProxy) public proxies;
}


contract MetaCoin is ERC1155, AccessControl, Pausable, ERC1155Burnable {
    bytes32 public constant URI_SETTER_ROLE = keccak256("URI_SETTER_ROLE");
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

    address proxyRegistryAddress;


    constructor(address _proxyRegistryAddress) ERC1155("https://abcoathup.github.io/SampleERC1155/api/token/{id}.json") {       
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setupRole(URI_SETTER_ROLE, msg.sender);
        _setupRole(PAUSER_ROLE, msg.sender);
        _setupRole(MINTER_ROLE, msg.sender);

        proxyRegistryAddress = _proxyRegistryAddress;
    }

    function setURI(string memory newuri) public onlyRole(URI_SETTER_ROLE) {
        _setURI(newuri);
    }

function pause() public onlyRole(PAUSER_ROLE) {
    _pause();
}

function unpause() public onlyRole(PAUSER_ROLE) {
    _unpause();
}

function supportsInterface(bytes4 interfaceId)
    public
    view
    override(ERC1155, AccessControl)
    returns (bool)
{
    return super.supportsInterface(interfaceId);
}

    function mint(address account, uint256 id, uint256 amount, bytes memory data)
        public
        onlyRole(MINTER_ROLE)
    {
        _mint(account, id, amount, data);
    }

    function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
        public
        onlyRole(MINTER_ROLE)
    {
        _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);
    }

  /**
   * Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-free listings.
   */
  function isApprovedForAll(
    address _owner,
    address _operator
  ) public override view returns (bool isOperator) {
    // Whitelist OpenSea proxy contract for easy trading.
    ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress);
    if (address(proxyRegistry.proxies(_owner)) == _operator) {
      return true;
    }

    return ERC1155.isApprovedForAll(_owner, _operator);
  }


}

💻 Environment 💻环境

node: v16.7.0节点:v16.7.0

deps:部门:

"@openzeppelin/contracts": "^4.3.0",
"@nomiclabs/buidler": "^1.4.8",
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomiclabs/hardhat-etherscan": "^2.1.1",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@openzeppelin/hardhat-upgrades": "^1.9.0",
"@typechain/ethers-v5": "^6.0.5",
"@typechain/hardhat": "^1.0.1",
"@types/chai": "^4.2.15",
"@types/chai-as-promised": "^7.1.3",
"@types/mocha": "^8.2.2",
"@types/node": "^14.14.37",
"chai": "^4.3.3",
"chai-as-promised": "^7.1.1",
"chai-datetime": "^1.8.0",
"ethereum-waffle": "^3.3.0",
"ethers": "^5.4.5",
"hardhat": "^2.6.1",
"hardhat-typechain": "^0.3.5",
"ts-generator": "^0.1.1",
"ts-node": "^9.1.1",
"typechain": "^4.0.3",
"typescript": "^4.2.4"

I finally found the root cause!我终于找到了根本原因! OpenSea expects a public property called name in order to display the proper Name of the Collection instead of a static label Unidentified contract . OpenSea 需要一个名为name的公共属性,以便显示集合的正确名称,而不是静态标签Unidentified contract

I came across this while looking at their reference code (which depends on a now 3-year-old MultiToken-Contract implementation and needs all in all some downgrades of Node and other tools in order to get it build [a downgrade to Node 10 worked best for me today] ).我在查看他们的参考代码时遇到了这个问题(这取决于现在已经有 3 年历史的MultiToken-Contract 实现,并且需要全部降级 Node 和其他工具才能构建它[降级到 Node 10 工作今天最适合我])。

This is taken from name in your contract.这取自您合同中的name

For ERC-1155 tokens, add a public variable name对于 ERC-1155 令牌,添加公共变量name

string public name = "My Collection Name";

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在solidity中查看用户是否有特定合约的ERC1155? - How to check whether user has any ERC1155 of specific contract in solidity? 你可以让 ERC1155 合约收到 ERC721 代币吗? - Can you make an ERC1155 contract receive an ERC721 token? 尝试编译合约但出现“ParserError:找不到源代码“@openzeppelin/contracts/token/ERC1155/IERC1155.sol”:找不到文件。” - Trying to compile contract but getting "ParserError: Source "@openzeppelin/contracts/token/ERC1155/IERC1155.sol" not found: File not found." 使用 Java Web3J 获取 ERC1155 钱包余额 - Getting ERC1155 Wallet Balance Using Java Web3J 以太坊安全帽 - NomicLabsHardhatPluginError:无法部署合约 ERC1155Facet 的抽象合约工厂 - Ethereum hardhat - NomicLabsHardhatPluginError: abstract contract factory for the contract ERC1155Facet can't be deployed ERC 1155 代币标准 - ERC 1155 Token Standard 来自自定义 ERC-1155 智能合约的 NFT 在 Etherscan for Goerli 测试网上未正确显示 - NFT from custom ERC-1155 smart contract not displaying correctly on Etherscan for Goerli test net 是否可以在不使用 openzepplin 库的情况下创建 erc721 合约并将其呈现在 opensea 上? - Is it possible to create an erc721 contract without using openzepplin library and render it on opensea? 如何将 ERC-721 智能合约与另一个智能合约连接起来 - How to connect a ERC-721 smart contract with another smart contract opensea 拍卖智能合约如何在不存储以太币的情况下工作 - How opensea auction smart contract work without storing the ether
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM