# Get Token Id after minting the NFT immediately from the contract as part of the transaction

**URL:** <https://forum.flow.com/t/get-token-id-after-minting-the-nft-immediately-from-the-contract-as-part-of-the-transaction/2217>\
**Category:** Uncategorized\
**Created:** [July 21, 2021, 7:31am UTC](https://forum.flow.com/t/get-token-id-after-minting-the-nft-immediately-from-the-contract-as-part-of-the-transaction/2217 "2021-07-21T07:31:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jain](https://avatars.discourse-cdn.com/v4/letter/j/f19dbf/32.png) [@Jain](https://forum.flow.com/u/Jain)\
**Post date:** [July 21, 2021, 7:31am UTC](https://forum.flow.com/t/get-token-id-after-minting-the-nft-immediately-from-the-contract-as-part-of-the-transaction/2217/1 "2021-07-21T07:31:16Z")

</div>

Hello everyone, I’m new to flow. I followed the NFT tutorial and successfully minted an NFT. However,  
I don’t get the Id of the token minted. I only get the transaction object which contains the transaction Id. I need the Id of the token minted for performing some operations on the metadata. Yes, I’m aware that I can run the getIds() script and get the whole array of the Token Ids stored but in my application continuous minting and depositing of token will take place and I won’t know which token Id belongs to my particular NFT which I just minted. Can you guys help me with this issue?

All I need is the token Id of the NFT Token I just minted in return.

let newNFT ← self.minterRef.mintNFT()

I get a newNFT in the above line which contains the id as well i.e. newNFT.id , but this is inside the transaction’s execute method in the frontend (I’m using FCL). So, this value is not accessible outside.  
and I only get transaction id in return. I need newNFT.id to store in my local DB.

I tried one more thing, I immediately called a script to fetch the latest token Ids array, but it return me the old array of Ids on immediate basis as the state of the blockchain get updated after a little time.  
When I run the fetch command again, it now returns the latest Ids array.

Please help me out people. I need NFT Id.

---

<div class="post-metadata">

**Author:** ![flowjosh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/flowjosh/32/362_2.png) [@flowjosh](https://forum.flow.com/u/flowjosh)\
**Post date:** [July 30, 2021, 4:03pm UTC](https://forum.flow.com/t/get-token-id-after-minting-the-nft-immediately-from-the-contract-as-part-of-the-transaction/2217/2 "2021-07-30T16:03:32Z")

</div>

Unfortunately, transactions do not have return values, so you can’t return the new ID immediately. You could emit an event with the new ID and check the results for that though! Do you think that would work for you?

---

<div class="post-metadata">

**Author:** ![sylv1un](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@sylv1un](https://forum.flow.com/u/sylv1un)\
**Post date:** [January 21, 2022, 8:57am UTC](https://forum.flow.com/t/get-token-id-after-minting-the-nft-immediately-from-the-contract-as-part-of-the-transaction/2217/4 "2022-01-21T08:57:30Z")

</div>

Hi,  
I have the same problem as Jain, and ok for your response but how can I get the informations on the emit event with fcl please ?  
Thanks for your help.

---

<div class="post-metadata">

**Author:** ![bruno](https://avatars.discourse-cdn.com/v4/letter/b/c77e96/32.png) [@bruno](https://forum.flow.com/u/bruno)\
**Post date:** [January 31, 2022, 4:30pm UTC](https://forum.flow.com/t/get-token-id-after-minting-the-nft-immediately-from-the-contract-as-part-of-the-transaction/2217/5 "2022-01-31T16:30:03Z")

</div>

I believe you can add events from your smart contract and then use FCL to catch them like this:

```auto
 const response = await fcl.send(
    await sdk.build([sdk.getEvents(eventType, from, toBlock)])
  );

  // Decode server response, so we could get properly formatted values
  const events = await fcl.decode(response);

```

---

<div class="post-metadata">

**Author:** ![sylv1un](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@sylv1un](https://forum.flow.com/u/sylv1un)\
**Post date:** [April 6, 2022, 7:21am UTC](https://forum.flow.com/t/get-token-id-after-minting-the-nft-immediately-from-the-contract-as-part-of-the-transaction/2217/6 "2022-04-06T07:21:34Z")

</div>

Thnaks Bruno 👌
