# Parse ContractId to Text

**URL:** <https://forum.canton.network/t/parse-contractid-to-text/5159>\
**Category:** App Development\
**Created:** [September 1, 2022, 12:04pm UTC](https://forum.canton.network/t/parse-contractid-to-text/5159 "2022-09-01T12:04:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rotoo](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/rotoo/32/3905_2.png) [@Rotoo](https://forum.canton.network/u/Rotoo)\
**Post date:** [September 1, 2022, 12:04pm UTC](https://forum.canton.network/t/parse-contractid-to-text/5159/1 "2022-09-01T12:04:45Z")

</div>

Hello Damlers,

I wan’t to parse a **ContractId** value that I get from **self** to a **Text** field. Is this possible?

> data Example = Example with  
> reference: Text

> …  
> create Example with reference = self

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [September 1, 2022, 12:21pm UTC](https://forum.canton.network/t/parse-contractid-to-text/5159/2 "2022-09-01T12:21:44Z")

</div>

You cannot convert between contract ids & Text in Daml. If you need such a conversion, you could do it on the client side, where you have some automation that reads the contract id and then inputs it as a Text somewhere else. That said, I’d say that’s usually an antipattern and you should treat contract ids as opaque values.

---

<div class="post-metadata">

**Author:** ![asarpeshkar](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/asarpeshkar/32/1601_2.png) [@asarpeshkar](https://forum.canton.network/u/asarpeshkar)\
**Post date:** [September 8, 2022, 4:35pm UTC](https://forum.canton.network/t/parse-contractid-to-text/5159/3 "2022-09-08T16:35:25Z")

</div>

If the use-case is storing contract ids of multiple types, you can wrap the contract ids in a type:

```haskell
data WrappedId = FooId (ContractId Foo) | BarId (ContractId Bar)

```

Of course this requires knowing what templates you want to track up front.
