I have a ERC1155 collection on opensea and I am trying to perform a check in my contract to see if the user owns any tokens from the collection, and how many. With ERC721 I was able to do this but I'm having issues with ERC1155 balanceOf -

require(IERC1155(0x00...).balanceOf(msg.sender) >= 1, "No tokens owned!");

I don't have the exact tokenID because it varies depending on what the user owns. How can I perform a check?


// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

contract test is ERC721URIStorage, Ownable {

using Strings for uint256;

constructor() ERC721("TEST", "TEST") {}

function viewBalance() external view returns (uint256) {return IERC1155(contractAddress).balanceOf(userAddress,tokenID);}


contractAddress, userAddress, tokenID - used as placeholders for the post. I'm placing the values directly in my code.

1 Answer 1


Unfortunately, you have to specify token id in erc1155. There is no way for doing it to a standard erc1155 contract.

  • I tried it but for some reason I'm getting an error - Wrong argument count for function call: 2 arguments given but expected 1. Any ideas as to why? balanceOf(wallet_address, tokenID); docs.openzeppelin.com/contracts/3.x/api/token/…
    – 730wavy
    Commented Feb 28, 2022 at 1:54
  • Are you sure you are using the correct interface or abi? Commented Feb 28, 2022 at 8:40
  • I believe so. I added my code in the question to show what I'm using
    – 730wavy
    Commented Feb 28, 2022 at 16:17
  • Nevermind, I was able to get it resolved. Thanks.
    – 730wavy
    Commented Mar 1, 2022 at 2:10
  • That is interesting. I didn't see any problem with your code. What was the problem? Commented Mar 2, 2022 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.