# Canister controller and cycle balance need to be public

**URL:** <https://forum.dfinity.org/t/canister-controller-and-cycle-balance-need-to-be-public/5591>\
**Category:** Developers\
**Created:** [June 30, 2021, 1:17am UTC](https://forum.dfinity.org/t/canister-controller-and-cycle-balance-need-to-be-public/5591 "2021-06-30T01:17:18Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![PaulLiu](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/paulliu/32/4701_2.png) [@PaulLiu](https://forum.dfinity.org/u/PaulLiu)\
**Post date:** [January 16, 2022, 2:36am UTC](https://forum.dfinity.org/t/canister-controller-and-cycle-balance-need-to-be-public/5591/21 "2022-01-16T02:36:28Z")

</div>

For people who are willing to make cycle balance public through the black hole canister, you now can enjoy an automatic topup service too!

Please see [Worry about your favorate canister running low on cycles? You got it covered!](https://forum.dfinity.org/t/worry-about-your-favorate-canister-running-low-on-cycles-you-got-it-covered/10307)

---

<div class="post-metadata">

**Author:** ![gohan](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/gohan/32/4626_2.png) [@gohan](https://forum.dfinity.org/u/gohan)\
**Post date:** [April 4, 2022, 2:16pm UTC](https://forum.dfinity.org/t/canister-controller-and-cycle-balance-need-to-be-public/5591/22 "2022-04-04T14:16:42Z")

</div>

Canister controllers and module hash is available through dfx using

```auto
❯ dfx canister --network ic info ivcos-eqaaa-aaaab-qablq-cai
Controllers: hgfyw-myaaa-aaaab-qaaoa-cai
Module hash: 0x2d8060fe316775976ad0a33975e846e98b649536be51c8bcf33a7c61806041c6

```

> <https://github.com/dfinity/sdk/blob/6c892b4ebc97ed9a62e900be4a8b3417a8b4f5ba/src/dfx/src/commands/canister/info.rs>

How to achieve same by using JavaScript?

---

<div class="post-metadata">

**Author:** ![gohan](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/gohan/32/4626_2.png) [@gohan](https://forum.dfinity.org/u/gohan)\
**Post date:** [April 4, 2022, 2:18pm UTC](https://forum.dfinity.org/t/canister-controller-and-cycle-balance-need-to-be-public/5591/23 "2022-04-04T14:18:36Z")

</div>

Also, by using nns/lifeline - [rno2w-sqaaa-aaaaa-aaacq-cai](https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.ic0.app/?id=rno2w-sqaaa-aaaaa-aaacq-cai) canister and method `canister_status` we can get Canister’s controllers information as an error.

 ![Screenshot 2022-04-04 at 2.26.01 PM](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/7/75e60c4471a8dd719973b52333272de67c4fe5e8.jpeg)

any other cleaner approach to get controllers and canister running status, module hash using js/httpAgent?

---

<div class="post-metadata">

**Author:** ![PaulLiu](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/paulliu/32/4701_2.png) [@PaulLiu](https://forum.dfinity.org/u/PaulLiu)\
**Post date:** [April 4, 2022, 8:50pm UTC](https://forum.dfinity.org/t/canister-controller-and-cycle-balance-need-to-be-public/5591/24 "2022-04-04T20:50:08Z")

</div>

dfx actually gets the controller and hash of a canister through [read\_state](https://smartcontracts.org/docs/interface-spec/index.html#http-read-state) call. You can also do that using low level API calls using agent-js.

However, only a controller of a canister can get its cycle balance and other info. This means, unless a canister’s controller purposely decides to expose such info to the public, they will remain private information.

One way for a developer to voluntarily expose such data is to use [the black hole canister](https://forum.dfinity.org/t/introduce-the-black-hole-to-help-with-canister-status-lookup-make-them-immutable/5755), simplying by adding the black hole canister id as one of the controllers of your own canister. Then others can send an update call `canister_status` to the black hole canister to get all status info including remaining cycle balance. It is useful and safe because the black hole canister itself is immutable. I also built a [TipJar service](https://forum.dfinity.org/t/worry-about-your-favorate-canister-running-low-on-cycles-you-got-it-covered/10307) to help monitor canister cycle balance and top up them when they run low, and of course, only those with blackhole as one of their controllers are supported.

[Previous page](https://forum.dfinity.org/t/canister-controller-and-cycle-balance-need-to-be-public/5591.md?page=1)
