I have unique requirements for a project. They are trying to issue ERC721 based badges/identities to the ICO participants. And utilize that identity/cert for sending reflection rewards via ERC20 contract. Say, there are 3 ICO phases : Phase A, Phase B & Phase C. Based on which bucket a particular user falls in, they will be getting bonus reflection dividends. Question I have is, how to reference the ERC721 badge/identity that are being issued during ICO and build a condition in the ERC721 contract (say If Wallet address was participated in Phase A then set reflection rewards as 1%)? If someone can explain this with an example, it will be greatly helpful.

1 Answer 1


It should be fairly easy for a contract to determine if an account owns any tokens. For example using balanceOf.

if (nftToken.balanceOf(msg.sender)) {
    // msg.sender owns at least one NFT

If you have the tokenId you could test for the owner

if (ownerOf(tokenId) == msg.sender) {
    // msg.sender owns

If you don't have the tokenId it is much harder to determine the tokens owned by an account. If the NFT supports ERC721Enumerable interface you could use it to enumera tokens owned by an account, but it will be expensive.

Probably the easiest thing to do if you own the NFT token is to add an explicit function to the contract and call it from the ERC-20 contract.

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.