# How can I track private function or contructor without event in subgraph?

**URL:** <https://forum.thegraph.com/t/how-can-i-track-private-function-or-contructor-without-event-in-subgraph/4636>\
**Category:** Questions\
**Tags:** subgraph-devs\
**Created:** [October 11, 2023, 8:28am UTC](https://forum.thegraph.com/t/how-can-i-track-private-function-or-contructor-without-event-in-subgraph/4636 "2023-10-11T08:28:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rick](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.thegraph.com/rick/32/2130_2.png) [@Rick](https://forum.thegraph.com/u/Rick)\
**Post date:** [October 11, 2023, 8:28am UTC](https://forum.thegraph.com/t/how-can-i-track-private-function-or-contructor-without-event-in-subgraph/4636/1 "2023-10-11T08:28:10Z")

</div>

Hi, I wrote and deployed the subgraph to hosted service for tracking all events of erc721 & 1155 on the network.  
Here, each nft item needs to save its image url in the subgraph.  
But \_setUri function is a private function on erc1155 and it is only called in constructor and furhtermore, it doesn’t have any event on it.  
So I can’t catch up on its event.  
How can I track this function for saving nft’s image url in the subgraph for erc721 & 1155 without tracking event? is this available?  
I hope your appreciate advices.

---

<div class="post-metadata">

**Author:** ![itsjerryokolo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.thegraph.com/itsjerryokolo/32/117_2.png) [@itsjerryokolo](https://forum.thegraph.com/u/itsjerryokolo)\
**Post date:** [October 11, 2023, 8:49am UTC](https://forum.thegraph.com/t/how-can-i-track-private-function-or-contructor-without-event-in-subgraph/4636/2 "2023-10-11T08:49:12Z")

</div>

Hi Rick,  
We support [callHandlers](https://thegraph.com/docs/en/developing/creating-a-subgraph/#call-handlers) & [BlockHandlers](https://thegraph.com/docs/en/developing/creating-a-subgraph/#block-handlers) as well. CallHandlers will trigger on a function call, but the issue here is that the function is private. A subgraph can’t track private functions.

---

<div class="post-metadata">

**Author:** ![Rick](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.thegraph.com/rick/32/2130_2.png) [@Rick](https://forum.thegraph.com/u/Rick)\
**Post date:** [October 11, 2023, 8:50am UTC](https://forum.thegraph.com/t/how-can-i-track-private-function-or-contructor-without-event-in-subgraph/4636/3 "2023-10-11T08:50:34Z")

</div>

thanks for reaching out. yeah, that’s it. I tried to use the callHandlers but the function was private so I couldn’t use it.  
Any solutions for tracking constructor in the graph?

---

<div class="post-metadata">

**Author:** ![itsjerryokolo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.thegraph.com/itsjerryokolo/32/117_2.png) [@itsjerryokolo](https://forum.thegraph.com/u/itsjerryokolo)\
**Post date:** [October 11, 2023, 8:53am UTC](https://forum.thegraph.com/t/how-can-i-track-private-function-or-contructor-without-event-in-subgraph/4636/4 "2023-10-11T08:53:08Z")

</div>

We don’t support triggering on the constructor yet.

---

<div class="post-metadata">

**Author:** ![adamfuller](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@adamfuller](https://forum.thegraph.com/u/adamfuller)\
**Post date:** [October 11, 2023, 10:04am UTC](https://forum.thegraph.com/t/how-can-i-track-private-function-or-contructor-without-event-in-subgraph/4636/5 "2023-10-11T10:04:43Z")

</div>

hi @Rick you should be able to call the contract state when a token is minted, e.g. to call `uri(tokenId)` ([docs](https://thegraph.com/docs/en/developing/assemblyscript-api/#access-to-smart-contract-state)) - note that if the base URI will be the same for all nfts, you could choose to only call this for the first token minted to speed up indexing

---

<div class="post-metadata">

**Author:** ![Rick](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.thegraph.com/rick/32/2130_2.png) [@Rick](https://forum.thegraph.com/u/Rick)\
**Post date:** [October 11, 2023, 1:10pm UTC](https://forum.thegraph.com/t/how-can-i-track-private-function-or-contructor-without-event-in-subgraph/4636/6 "2023-10-11T13:10:12Z")

</div>

thanks. @adamfuller  
I can see the way to get the symbol (state) of erc20 contract.  
if so, can I get public view function same way in erc721?

```auto
    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual returns (string memory) {
        _requireOwned(tokenId);

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : "";
    }

```

this is a public view function to get tokenUri of erc721.

can I use like this?

```auto
  let contract = ERC721Contract.bind(event.address)
  let erc721TokenURI = contract.tokenURI(tokenId)

```

thanks

---

<div class="post-metadata">

**Author:** ![adamfuller](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@adamfuller](https://forum.thegraph.com/u/adamfuller)\
**Post date:** [October 30, 2023, 10:55am UTC](https://forum.thegraph.com/t/how-can-i-track-private-function-or-contructor-without-event-in-subgraph/4636/8 "2023-10-30T10:55:41Z")

</div>

👍 yes @Rick, assuming you have the ERC721 ABI accessible that should work
