The OpenZeppelin ERC-721 library has a function called balanceOf(address owner)
, which enables one to know how many tokens an address owns. Furthermore, one can also use a mapping in order to keep track of how many tokens an address owns, such as mapping(address => uint) ownerCount
.
What are the advantages of using one over the other (in terms of gas cost and performance for instance), and when should one be used instead of the other?
Thank you. J