# How do cycles work with asset canisters

**URL:** <https://forum.dfinity.org/t/how-do-cycles-work-with-asset-canisters/4065>\
**Category:** Developers\
**Created:** [May 20, 2021, 10:42am UTC](https://forum.dfinity.org/t/how-do-cycles-work-with-asset-canisters/4065 "2021-05-20T10:42:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cryptoschindler](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/cryptoschindler/32/26_2.png) [@cryptoschindler](https://forum.dfinity.org/u/cryptoschindler)\
**Post date:** [May 20, 2021, 10:42am UTC](https://forum.dfinity.org/t/how-do-cycles-work-with-asset-canisters/4065/1 "2021-05-20T10:42:03Z")

</div>

I have a couple of questions regarding cycle management and asset canisters:

1. How can i send cycles to an asset canister?  
It seems like I can only create an asset canister with a certain inital cycle balance, but I’m not able to top it up as the method `wallet_receive` is not available. I found `deposit_cycles` in the interface [spec](https://sdk.dfinity.org/docs/interface-spec/index.html) but I’m not sure if this is the right approach. If so, how would i specify the amount of cycles i want to deposit from the command line?

2. How are cycles deducted from the asset canisters cycle balance in the wallet UI?  
No matter how often I open the URL where my asset canister is running, I can never observe a deduction of cycles in the wallet UI. I believe this is a bug. `dfx canister status` shows a reduced amount of cycles correctly.

3. Why is my wallets cycle balance constantly shrinking?  
I can observe that my cycle balance is constantly shrinking, why is that?  
My guess would be that the wallet canister has to pay for it’s own storage.

4. How can I “save” cycles from an asset canister I want to delete?

5. Why does `dfx canister status` show a `Memory allocation` and `Compute allocation` of 0 for an asset canister?

6. Do we pay for traffic and storage or storage only?

Basically I want to be able to take action and load up a canister with cycles when I see it’s running out of them which currently doesn’t seem to work out of the box for an asset canister.

Tagging @anon74414410 @prithvi @nomeata for visibility.

---

<div class="post-metadata">

**Author:** ![cryptoschindler](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/cryptoschindler/32/26_2.png) [@cryptoschindler](https://forum.dfinity.org/u/cryptoschindler)\
**Post date:** [May 20, 2021, 11:14am UTC](https://forum.dfinity.org/t/how-do-cycles-work-with-asset-canisters/4065/2 "2021-05-20T11:14:05Z")

</div>

RE 1:  
Yes it is, you can use `deposit_cycles`

```bash
dfx canister --network ic call --with-cycles 1000000000000 aaaaa-aa deposit_cycles '(record {canister_id = principal "<canister-principal>"})'

```

Transactions using this method do not show up in the wallet UI, is this a bug?

Another possible solution if you only have ICPs at hand:

```bash
dfx ledger top-up

```

---

<div class="post-metadata">

**Author:** ![prithvi](https://avatars.discourse-cdn.com/v4/letter/p/22d042/32.png) [@prithvi](https://forum.dfinity.org/u/prithvi)\
**Post date:** [May 20, 2021, 5:01pm UTC](https://forum.dfinity.org/t/how-do-cycles-work-with-asset-canisters/4065/3 "2021-05-20T17:01:08Z")

</div>

1. The command you posted is right, but dfx will have a `dfx canister deposit-cycles` in the next release to make this easier.
2. I think the wallet UI only reports its own cycle balance, not of other canisters (asset canisters or otherwise.) Unless that changed in the last release (I haven’t used the UI - but can double check.)
3. You’re right, the wallet is just like any other canister and has to pay (in cycles) for the resources it consumes.
4. There’s no management canister method/system api that enables a controller to extract cycles from a canister and deposit them somewhere else. So the developer will have to cook up their own solution to “save” cycles. A stopgap could be to reinstall a wallet wasm (or some other canister which allows cycle sending) onto the target canister. Not nice but that’s what we have for now.
5. Did you set `initialization_values` in dfx.json? If not, and you did a `dfx deploy` both values will be set to `None` and will show up as `0` when calling `canister_status`; this is the same for the non assets canister. You can increase the memory/compute allocation via `dfx canister update-settings`
6. The official cycle cost documentation is being worked on and should be published soon. I can refer you to that once its out.

---

<div class="post-metadata">

**Author:** ![cryptoschindler](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/cryptoschindler/32/26_2.png) [@cryptoschindler](https://forum.dfinity.org/u/cryptoschindler)\
**Post date:** [May 21, 2021, 8:04am UTC](https://forum.dfinity.org/t/how-do-cycles-work-with-asset-canisters/4065/4 "2021-05-21T08:04:10Z")

</div>

Many thanks, great answer!

> [@prithvi](#):
>
> Did you set `initialization_values` in dfx.json? If not, and you did a `dfx deploy` both values will be set to `None` and will show up as `0` when calling `canister_status` ; this is the same for the non assets canister. You can increase the memory/compute allocation via `dfx canister update-settings`

How do those values relate to performance? What changes for my asset canister if I bump those up to the max value?

Both values initally set to zero seems odd, as it implies there is no computing capacity and zero memory available to the canister, but of course it still runs.

---

<div class="post-metadata">

**Author:** ![prithvi](https://avatars.discourse-cdn.com/v4/letter/p/22d042/32.png) [@prithvi](https://forum.dfinity.org/u/prithvi)\
**Post date:** [May 21, 2021, 2:00pm UTC](https://forum.dfinity.org/t/how-do-cycles-work-with-asset-canisters/4065/5 "2021-05-21T14:00:37Z")

</div>

You can read about what those settings mean for your canister here: [The Internet Computer Interface Specification :: Internet Computer](https://sdk.dfinity.org/docs/interface-spec/index.html#ic-create_canister)

---

<div class="post-metadata">

**Author:** ![cryptoschindler](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/cryptoschindler/32/26_2.png) [@cryptoschindler](https://forum.dfinity.org/u/cryptoschindler)\
**Post date:** [May 21, 2021, 2:16pm UTC](https://forum.dfinity.org/t/how-do-cycles-work-with-asset-canisters/4065/6 "2021-05-21T14:16:47Z")

</div>

So 0 means unbounded for compute allocation?
