Giter VIP home page Giter VIP logo

Comments (8)

xpepermint avatar xpepermint commented on May 28, 2024 1

@erectilereptiles please edit your question and put your code into '''sol ... ''' brackets. It's very difficult to read code in the current format (as text).

from erc721.

erectilereptiles avatar erectilereptiles commented on May 28, 2024 1

@erectilereptiles please edit your question and put your code into '''sol ... ''' brackets. It's very difficult to read code in the current format (as text).

sorry about that!

from erc721.

MoMannn avatar MoMannn commented on May 28, 2024

@erectilereptiles If you want to list tokens you should look at enumerable extension:
https://github.com/0xcert/ethereum-erc721/blob/master/src/contracts/mocks/nf-token-metadata-enumerable-mock.sol

Enumerable adds a few new methods:
https://github.com/0xcert/ethereum-erc721/blob/master/src/contracts/tokens/erc721-enumerable.sol

This way you can call: totalSupply to get amount of existing tokens and iterate from 0 < totalSupply and call tokenByIndex to get IDs of all existing tokes.

Similarly you can call balanceOf(owner) to get amount of user tokens and then iterate and call tokenOfOwnerByIndex to get that specific owners tokens.

For each ID you get you can then call tokenUri or other functions to get details you are interested about.

Hope this answers your question.

from erc721.

erectilereptiles avatar erectilereptiles commented on May 28, 2024

@MoMannn Thank you so much for this! I will try implementing it as soon as i can and maybe get back to you if have any trouble? If thats okay!

from erc721.

erectilereptiles avatar erectilereptiles commented on May 28, 2024

@MoMannn Sorry i am just a bit confused as to how i get the enumerable extension? Is the enumerable extension all of the regular functionality with the addition of things like total supply? I simply used the example implementation given on the page. I am using Remix IDE. How to i instead import the one that includes the total supply functions and whatever else is included in the enumerable extension? I really appreciate all of the help you are providing me with as a student it is valuable for learning!

from erc721.

MoMannn avatar MoMannn commented on May 28, 2024

The example is only with metedata extension. Check the code here to see how to use enumerable extension:

https://github.com/0xcert/ethereum-erc721/blob/master/src/contracts/mocks/nf-token-metadata-enumerable-mock.sol

You can also checkout tests to see some basic usage:

https://github.com/0xcert/ethereum-erc721/blob/master/src/tests/tokens/nf-token-metadata-enumerable.js

Otherwise I would suggest reading and learning more about erc721 and how it works:

from erc721.

erectilereptiles avatar erectilereptiles commented on May 28, 2024

@MoMannn Thank you so much! I totally understand what you are saying after playing around in remix a bit! I just want a bit of advice maybe and then the issue can be closed! So i can call the total supply method in react.js (which is what we are using for our interface) and then the console logs the correct number! My though process is creating an array from 0 up until total supply. So with 5 tokens out we'll have 0,1,2,3,4 in an array. Then use a foreach statement to pass each number in the array to tokenbyindex to get the ids, then add all ids to another array. Similarly, use a foreach statement for each number (id) in the second array to get all info for each token id. Is this a good solution? Also should all of this be done in the app.js correct? Or do you think there would be a better way to do some of it in remix itself? Any info is appreciated and then the comment can be closed! Thanks so much for all your help its been invaluable.

from erc721.

MoMannn avatar MoMannn commented on May 28, 2024

That is the correct way yes. if you want tokens for only specific user you call balanceOf(address) and then tokenOfOwnerByIndex(address, index).

You should do this in app.js and it he only way to get this information directly from chain.

Ok, then I am closing this issue. Glad I could help.

from erc721.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.