# I’m developing an escrow-style contract that needs to both receive and later release coins using the documented methods

**URL:** <https://forum.midnight.network/t/i-m-developing-an-escrow-style-contract-that-needs-to-both-receive-and-later-release-coins-using-the-documented-methods/562>\
**Category:** Technical Questions\
**Created:** [October 27, 2025, 9:59am UTC](https://forum.midnight.network/t/i-m-developing-an-escrow-style-contract-that-needs-to-both-receive-and-later-release-coins-using-the-documented-methods/562 "2025-10-27T09:59:56Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![bochaco](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.midnight.network/bochaco/32/112_2.png) [@bochaco](https://forum.midnight.network/u/bochaco)\
**Post date:** [October 27, 2025, 3:09pm UTC](https://forum.midnight.network/t/i-m-developing-an-escrow-style-contract-that-needs-to-both-receive-and-later-release-coins-using-the-documented-methods/562/2 "2025-10-27T15:09:52Z")

</div>

If I understand your doubt correctly, I believe you are referring to something like the following for deposits:

```auto
// Contract's own treasury of native tokens.
export ledger treasury: QualifiedCoinInfo;

export circuit depositFunds(coinInfo: CoinInfo): [] {
  assert(coinInfo.color == nativeToken(), "Only native tokens can be deposited");
  receive(disclose(coinInfo));
  const me = right<ZswapCoinPublicKey, ContractAddress>(kernel.self());
  treasury.writeCoin(disclose(coinInfo), me);
  return [];
}

```

Then to send coin from the ledger’s `QualifiedCoinInfo` you should be able to do something like this:

```auto
  const sender = left<ZswapCoinPublicKey, ContractAddress>(ownPublicKey());
  const sendResult = send(treasury, sender, disclose(amount));
  assert(sendResult.sent.value == amount, "Failed to send withdrawal payment");
  if (sendResult.change.is_some) {
     const me = right<ZswapCoinPublicKey, ContractAddress>(kernel.self());
     treasury.writeCoin(sendResult.change.value, me);
  } else {
     treasury.resetToDefault();
  }

```

Although, bear in mind what it’s being discussed in this issue related to circuits like the above: [Cannot receive coins from a contract · Issue #63 · midnightntwrk/community-hub · GitHub](https://github.com/midnightntwrk/community-hub/issues/63).

---

_[View the full topic](https://forum.midnight.network/t/i-m-developing-an-escrow-style-contract-that-needs-to-both-receive-and-later-release-coins-using-the-documented-methods/562)._
