Solidity OpenZeppelin – Using getBalanceOf() to Retrieve ERC1155 Token Balance from a Given Address

openzeppelinsolidity

I was looking for simple implementation of checking balanceOf ERC1155 with given _tokenId using openzeppelin library but I haven't found any. Please Help me how can I use this method in smartcontract by showing any smple function with correct constructor settings

function balanceOf(address owner) external view returns (uint256);

Best Answer

You should be able to use the balanceOf function defined in EIP-1155. This is also available on the OpenZepplin implementation: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/ERC1155.sol#L70