How to get token id from NFT contract
I have created an NFT with the help of openzeppelin wizard. I got the following response on mintable method.
I am not sure how to get the tokenId from this response. I am running it to truffle console. I have tried different solutions from this stackexchange but as you see that i haven’t received the topics[] arg under the log. I am using Solidity 0.8.2 version.
1 Answer 1
Okay, i have solved it and i hope it will help to other newbies too like me. The tokenId exists in the rawLogs data.
So get the tokenId i have used the web3 utility.
Note: I used the truffle console for all that.
-
The Overflow Blog
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.10.19.43685
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
How to get NFT token IDs via Covalent API
In this quick tutorial, I’ll show you how to get a wide variety of data from the blockchain network using the Covalent API. How to get your own Covalent API for this actions, what information can be extracted using the covalent API in Covalent Docs, and much more.
Before you start working with the Covalent API in Covalent Docs, you need to get your API key. To get it, you need to go to https://www.covalenthq.com/ and register your account.
After completing the quick registration procedure, you will be able to receive your API key. It will look like this ( I hid the last few characters of my key because I’m greedy):
So now that you have obtained the required API key, you can start working in Covalent Docs.
Then I recommend that you familiarize yourself with the Overview tab to understand exactly what Covalent Docs are and how teams work. Then, by going to the Changelog tab,
You need to enter your API key before starting to get the information correctly. Some commands from ClassA can work without obtaining an API key, such as Get token balances for address and Get historical portfolio value over time.
Having done all the preparatory steps before working with the API, you can start working with more interesting options. In this article, we will cover the section Get NFT Token IDs.
Get NFT Token IDs real-time
GET /v1/
/nft_token_ids//tokens/ Returns a list of all token IDs for a NFT contract on a blockchain network.
PATH PARAMETERS
- chain_id — in this field you need to enter the network in which you are going to work. Currently supports 1 for Ethereum Mainnet, 137 for Polygon/Matic Mainnet, 80001 for Polygon/Matic Mumbai Testnet, 56 for Binance Smart Chain, 43114 for Avalanche C-Chain Mainnet, 43113 for Fuji C-Chain Testnet, and 250 for Fantom Opera Mainnet.
- address — in this field you need to enter the smart contract address
QUERY-STRING PARAMETERS
- page-number — in this field you need to enter the specific page to be returned.
- page-size — in this field you need to enter the number of results per page.
- format — in this field you need to enter the format of response. CSV or JSON
As an example, I decided to consider Polkamon NTF tokens smart-contract. So I filled in the fields with the following data:
How to find NFT metadata on OpenSea and Rarible?
With the right API, contract address and token id, anyone can find NFT metadata on OpenSea and Rarible.
Join us on social networks
NFTs are a game-changing technology, providing ownership for digital assets and serving as certificates for holders or access keys for the underlying content, which could be music, movies, art, real estate, and a lot of other stuff. However, what makes nonfungible tokens (NFTs) useful in real terms is metadata. It may not be a buzzword exactly but it ensures the user is able to make out what the NFT is all about.
Metadata is information about the content that an NFT represents. As large files cannot be stored on the blockchain for the simple reason that they become too expensive, NFTs, most of the time, just point to the files stored outside the blockchain. That said, only a few NFT artworks are stored on-chain.
This article explains NFT metadata, what makes putting up content on blockchain impractical, and how to find NFT metadata on Opensea and Rarible. Let’s start with understanding what NFT metadata actually is.
What is nonfungible token (NFT) metadata?
An NFT refers to a specific digital asset that could be in the form of a JPEG, GIF or an MP4 file. Though the token itself is hosted on the blockchain, the file underneath is stored off-chain. NFT metadata points out specifications regarding that stored data. It might include information such as the NFT’s name, description of the NFT, transactional history, link to the hosted image, traits and more.
As for the advantages of NFT metadata, it helps solution architects to set aside the technical issues when hosting large files on a chain. The preferred practice is to upload the link of the content to the blockchain while storing content on an HTTP URL on the current Internet or the InterPlanetary File System (IPFS).
IPFS is a file-sharing peer-to-peer (P2P) network for storing and sharing data in a distributed file. The metadata serves as the input of the NFT smart contract one needs to deploy on the blockchain network.
Metadata is specified in a standardized JavaScript Object Notation (JSON) format. Inside the smart contract, though, the information is stored as a Universal Resource Identifier (URI) as storing as a JSON is too demanding on resources. However, users can download NFT metadata at will.
Why is metadata for off-chain data needed?
The large size of images, audio and video content makes uploading it to the blockchain very expensive. For instance, if someone wanted to store one gigabyte of data on the Ethereum blockchain, it would cost an approximate equivalent of $35 million. If a movie of 160 odd minutes is stored on a blockchain, it might cost more than the expenses of making the film, i.e., $237 million.
The URI string, as mentioned above, indicates a location where one can find the token’s JSON description. The relevant metadata stays as a permanent record on the blockchain, describing what the token represents.
What Opensea and Rarible add to the NFT ecosystem?
Huge demand for NFTs led to the need for marketplaces where users can create, transfer and monetize their assets. The marketplaces provide the tools for these activities, which are so crucial for keeping up the NFT movement. Topping the chart are Opensea and Rarible, two open platforms where anyone can mint and trade NFTs.
OpenSea is the world’s first and largest marketplace for NFTs, enabling users to roll out their own NFT collections to sell on the platform. Simplifying the intricate processes required for managing and monetizing NFTs, OpenSea provides the infrastructure for minting, listing and trading NFTs. Initially built to support CryptoKitties, OpenSea has grown to become NFT participants’ go-to marketplace.
Rarible is also a peer-to-peer (P2P) gateway into the NFT market, offering simple minting and trading features. Unlike OpenSea, Rarible deploys its native token, RARI, to govern the platform and enable holders of RARI to vote on critical decisions.
How to view NFT metadata on OpenSea?
Any seasoned trader will want to view NFT metadata on OpenSea to find out what the NFT is all about. Checking metadata on OpenSea is pretty simple. For ease of understanding, let us focus on finding metadata of NFTs based on Ethereum.
The process is as follows:
1. Open the NFT they want to get metadata for.
2. Scroll down and click on the “Details” tab and click the link next to the contract address.
3. In the Etherscan link that appears on the screen, then copy the contract address.
4. The user now types api.opensea.io/asset/ in the URL text box and pastes the copied contract address after slash at the end of the URL, followed by the token ID mentioned in contract details.
The metadata in JSON format appears on the screen. To find metadata of NFTs hosted on other blockchains, one uses a relevant blockchain explorer to get the contract address. For instance, if the NFT is hosted on the Solana blockchain, clicking the link next to “Contact Address” on the “Details” tab takes one to Solana explorer Solscan.io. One can then use the relevant API to get the metadata.
How to find NFT metadata on Rarible?
Like OpenSea, Rarible also offers a way to find information regarding metadata. To understand the process, let’s use a popular NFT based on the Ethereum blockchain called EXIO, the pilot who enters the atmosphere of a planet controlled by psychedelic consciousness.
Here’s the process to find NFT metadata for EXIO on Rarible:
1. On Rarible, the user opens the respective page of the NFT, such as EXIO, as shown in the image below.
2. Scroll the screen downwards. Under the Details tab, click View on Etherscan.
3. From the screen, click on the Token ID number in blue.
4. The user will now be directed to a new page.
5. Copy the contract address.
6. To find metadata, plug in the following link in the given format.
https://api.rarible.org/v0.1/items/ETHEREUM:Contract Address: Token id
For the given contract address, the link will be
The metadata will appear on the screen.
To find metadata of the NFTs hosted on blockchains other than Ethereum on Rarible, all one needs to do is replace Ethereum with another blockchain of their choice. In some cases, there is no token ID. Below are examples for each particular blockchain represented on Rarible:
Take metadata into account when trading on OpenSea and Rarible
Metadata helps users to focus on the ownership and tradability of NFTs, thus making the tokens applicable in a string of use cases like art, real estate, music, fashion, gaming, supply chain, luxury goods, ticket sales and more. Immediate access to this important data brings efficiency to real-world implementations of NFT technology. Active usage of metadata by the users will promote stability in the ecosystem, adding tremendous value to it.
A big chunk of traders on platforms like OpenSea and Rarible tend to look at metadata as technical stuff and don’t bother to check it. However, any experienced trader would know how important it is to know about every possible stuff about the NFTs they are going to purchase. Both platforms provide users with simple ways to find metadata about the specific NFTs and ensure the tokens they buy are worth the deal.
Purchase a licence for this article. Powered by SharpShark.
How to Find NFT Contract Address on OpenSea and Read It
A contract address of an NFT reveals the complete information about the NFT, such as ownership details, maximum total supply, number of holders, details of all transactions, and more.
Also, you will need the NFT contract address to view NFTs in the MetaMask wallet or any other Web 3 wallets.
How to Find NFT Contract Address on OpenSea?
To find NFT contract address on OpenSea, go to OpenSea and select the NFT for which you want to see the contract address.
Then, scroll down to reach the “ Details ” tab and click on it.
Steps to Find NFT Contract Address on OpenSea
1. Go to OpenSea
Visit the OpenSea website, the largest NFT marketplace.
OpenSea has all kinds of NFTs, including art, collectibles, domain names, music, photography, sports, trading cards, and virtual worlds.
2. Locate the NFT
After getting onto the OpenSea website, you can find the NFT that you are looking for using the search box given.
Alternatively, you can click the “ Explore ” button to search for NFT by category.
If you have NFT in your wallet and want to see the contract address, you need to connect your MetaMask , Trust Wallet , Coinbase Wallet , Phantom Wallet , or any other wallet to OpenSea.
After establishing the connection between your wallet and OpenSea, you need to click the “ Profile Icon ” in the upper right corner of the webpage.
Now, on the “ Collected ” tab, you will be able to see your NFTs.
Click on the NFT for which you want to see the contract address.
3. Expand “ Details ” Tab
Once you have located the NFT, you need to scroll a bit down to see the “ Details ” tab.
Expand the Details tab by clicking on it.
By doing so, you will be able to see the contract address and the token ID of the NFT that you have selected.
Now, you can use it to import the NFT into crypto wallets or read the complete information about that NFT.
Click on the contract address to see the complete details of the NFT on the blockchain explorer.
4. Read the Smart Contract
On the blockchain explorer, you will find many attributes. Each attribute holds specific information about the NFT.
Contract Creator : This attribute holds the transaction id (TxID) of the creator of the NFT. Clicking this TxID will reveal the details, such as when the NFT was created, blocks confirmed, transaction fee, and smart contract ID.
Token Tracker : The Token Tracker attributes hold the maximum total supply of the NFT, total holders, and total transactions so far, along with the transaction details.
It also contains the official website and social profiles of the NFT creator.
Transactions : The Transactions tab records all the real-time transactions along with the From and To addresses, time stamps, transaction fee, method, and blocks.
The Method attribute under the Transactions tab has three statuses: Set Approval For All, Mint , and Transfer From . It is updated based on the decoded input.
Internal Txns : Internal transactions are transactions between smart contracts. You can see From and To addresses, timestamp, block, and value.
Contract : This is where you can see, read, and interact with the smart contract of the NFT. The Contract tab has three sub-tabs called Code , Read Contract , and Write Contract .
Under the “ Code”, you can find the complete smart contract’s source code. On the Read Contract tab, you can read the smart contract by method-wise. To use the Write Contract feature, you need to connect your Web 3 wallet. Be aware that this feature of connecting Web 3 wallet is a beta version hence, use it cautiously.
Analytics : This tab features multiple charts detailing the Ether balance, transactions, TxnFees, Ether transfers, and token transfers. It also has a new feature called Txn Heatmap.
Apart from these attributes, you can also find ERC20 Token Txns, ERC721 Token Txns, events, and comments, which are less important than the attributes we explained.
Conclusion
Finding NFT contract address and token ID on OpenSea is a pretty easy task.
Interpreting them would be a bit complicated for many. However, if you read the way we have explained in this article (Step 4), you will know the complete details of the NFT you hold or are looking for.
After finding the Contract address and token ID of NFT, you can interpret them or use them to import the NFT into your Web 3 wallets.