# Converting one interface to another

**URL:** <https://forum.canton.network/t/converting-one-interface-to-another/5889>\
**Category:** App Development\
**Tags:** interfaces, daml, daml-finance\
**Created:** [January 2, 2023, 6:07pm UTC](https://forum.canton.network/t/converting-one-interface-to-another/5889 "2023-01-02T18:07:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cohen.avraham](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/32.png) [@cohen.avraham](https://forum.canton.network/u/cohen.avraham)\
**Post date:** [January 2, 2023, 6:07pm UTC](https://forum.canton.network/t/converting-one-interface-to-another/5889/1 "2023-01-02T18:07:26Z")

</div>

G-d willing

Hi everyone,  
I am having some difficulties in converting one interface to another from within a `Script`.  
I am using the Finance Library trying to convert a Holding to Fungible.

```haskell
import Daml.Finance.Interface.Holding.Base qualified as Holding
import Daml.Finance.Interface.Holding.Fungible qualified as Fungible

convertHoldingToFungible : ContractId Holding.I -> Party -> Script ()
convertHoldingToFungible holdingCid owner = do
  fungibleHoldingCid <- toInterfaceContractId @Fungible.I holdingCid
  pure ()

```

The line that is doing `toInterfaceContractId` is having an error indicating:

```haskell
    • Couldn't match type ‘ContractId’ with ‘Script’
      Expected type: Script Fungible.I
        Actual type: ContractId Fungible.I

```

However, when I am doing it this way, it works:

```haskell
  fungibleHoldingCid <- toInterfaceContractId @Fungible.I . fst . head <$> queryInterface @Fungible.I owner

```

Can you please explain to me how can I do it correctly?

Thanks,

---

<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:** [January 3, 2023, 7:56am UTC](https://forum.canton.network/t/converting-one-interface-to-another/5889/2 "2023-01-03T07:56:04Z")

</div>

If you bind a value `x <- expr` in a do block, `expr` needs to have type `m a` where `m` is the type of the `Action` you’re do block is for. `x` will then have type `a`. If you just want to use a local variable use `let x = expr` instead where `expr` can have any type `t` and `x` will also have type `t`.

In your example `m = Script` but `toInterfaceContractId @Fungible.I holdingCid` has type `ContractId Fungible.I`.

So try this instead:

```haskell
convertHoldingToFungible : ContractId Holding.I -> Party -> Script ()
convertHoldingToFungible holdingCid owner = do
  let fungibleHoldingCid = toInterfaceContractId @Fungible.I holdingCid
  pure ()

```

That function itself is not very useful though since younever use `fungibleHoldingCid`. Maybe you intended to return it from the function?
