Comments (8)
@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 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.
@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.
@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.
@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.
The example is only with metedata extension. Check the code here to see how to use enumerable extension:
You can also checkout tests to see some basic usage:
Otherwise I would suggest reading and learning more about erc721 and how it works:
- https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
- https://www.quicknode.com/guides/solidity/how-to-create-and-deploy-an-erc-721-nft
from erc721.
@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.
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)
- Support latest Solidity
- Update list of supported Node.js versions
- import nf-token-metadata.sol and ownable.sol in the remix. But it says ‘not found’ HOT 1
- Support Solidity 0.8.4
- NatSpec style: use @notice before @dev HOT 1
- 721
- Warning: SPDX license identifier not provided in source file HOT 2
- Release new npm version HOT 1
- Created NFT has no creator HOT 4
- Not an issue just need some advice! HOT 8
- Question about error constants HOT 2
- Make metadata tokenURI overridable. HOT 1
- Fix dependency status icon
- Update branding HOT 1
- Cannot find json under "@nibbstack/erc721/build/" HOT 4
- Cheaper ERC-165 implementation HOT 2
- No need for assembly for code hash
- What is the meaning behind the error constants?
- Metadata extension JSON schema
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from erc721.