# Reject text: IC0503: Canister ypg3d-6qaaa-aaaah-aasgq-cai trapped explicitly: arithmetic overflow

**URL:** <https://forum.dfinity.org/t/reject-text-ic0503-canister-ypg3d-6qaaa-aaaah-aasgq-cai-trapped-explicitly-arithmetic-overflow/10276>\
**Category:** Developers\
**Created:** [January 13, 2022, 7:19pm UTC](https://forum.dfinity.org/t/reject-text-ic0503-canister-ypg3d-6qaaa-aaaah-aasgq-cai-trapped-explicitly-arithmetic-overflow/10276 "2022-01-13T19:19:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chepreghy](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/chepreghy/32/13894_2.png) [@chepreghy](https://forum.dfinity.org/u/chepreghy)\
**Post date:** [January 13, 2022, 7:19pm UTC](https://forum.dfinity.org/t/reject-text-ic0503-canister-ypg3d-6qaaa-aaaah-aasgq-cai-trapped-explicitly-arithmetic-overflow/10276/1 "2022-01-13T19:19:30Z")

</div>

I recently started getting this error:

```auto
index.js:2 Error: Call was rejected:
  Request ID: 2d36e3ff2aac0cb1cedc70eb318ed103e8ccf9db2d168f570ac371aaf8679e8b
  Reject code: 4
  Reject text: IC0503: Canister ypg3d-6qaaa-aaaah-aasgq-cai trapped explicitly: arithmetic overflow

    at uo (index.js:2)
    at async r (index.js:2)
    at async Object.Oa [as mutationFn] (index.js:2)

```

and I’m not quite sure what the problem can be or how to debug this. Do you guys have any idea what I can start looking into? Thanks in advance?

The bug can be reproduced by:

- Going to [https://graci-aaaaa-aaaah-aaqjq-cai.raw.ic0.app/](https://graci-aaaaa-aaaah-aaqjq-cai.raw.ic0.app/)
- Connect stoic or Plug / choosing a username
- Clicking “Arena”, choosing the 3 free ICmojis
- Choose a random strategy and click “fight!”

The thing is, it works half the time, so I really don’t know what goes wrong. Any help is greatly appreciated!

---

<div class="post-metadata">

**Author:** ![diegop](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/diegop/32/569_2.png) [@diegop](https://forum.dfinity.org/u/diegop)\
**Post date:** [January 14, 2022, 5:57am UTC](https://forum.dfinity.org/t/reject-text-ic0503-canister-ypg3d-6qaaa-aaaah-aasgq-cai-trapped-explicitly-arithmetic-overflow/10276/2 "2022-01-14T05:57:07Z")

</div>

Tbh not sure who to even ask. Let me ping some folks.

---

<div class="post-metadata">

**Author:** ![flyq](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/flyq/32/3637_2.png) [@flyq](https://forum.dfinity.org/u/flyq)\
**Post date:** [January 14, 2022, 6:25am UTC](https://forum.dfinity.org/t/reject-text-ic0503-canister-ypg3d-6qaaa-aaaah-aasgq-cai-trapped-explicitly-arithmetic-overflow/10276/3 "2022-01-14T06:25:46Z")

</div>

maybe there is overflow bug in your motoko/rust code.

---

<div class="post-metadata">

**Author:** ![nomeata](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nomeata/32/733_2.png) [@nomeata](https://forum.dfinity.org/u/nomeata)\
**Post date:** [January 14, 2022, 3:32pm UTC](https://forum.dfinity.org/t/reject-text-ic0503-canister-ypg3d-6qaaa-aaaah-aasgq-cai-trapped-explicitly-arithmetic-overflow/10276/4 "2022-01-14T15:32:28Z")

</div>

Definitely Motoko. You might be using bounded types (`Nat8` etc.) and they are overflowing, or you might be using `Nat` and some subtraction turns out to underflow.

---

<div class="post-metadata">

**Author:** ![chepreghy](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/chepreghy/32/13894_2.png) [@chepreghy](https://forum.dfinity.org/u/chepreghy)\
**Post date:** [January 15, 2022, 7:56am UTC](https://forum.dfinity.org/t/reject-text-ic0503-canister-ypg3d-6qaaa-aaaah-aasgq-cai-trapped-explicitly-arithmetic-overflow/10276/5 "2022-01-15T07:56:06Z")

</div>

That’s great! Then it shouldn’t be that hard to find. Is there a way to know which line or which function causes the overflow? How do you guys normally debug something like this?

---

<div class="post-metadata">

**Author:** ![nomeata](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nomeata/32/733_2.png) [@nomeata](https://forum.dfinity.org/u/nomeata)\
**Post date:** [January 15, 2022, 9:52am UTC](https://forum.dfinity.org/t/reject-text-ic0503-canister-ypg3d-6qaaa-aaaah-aasgq-cai-trapped-explicitly-arithmetic-overflow/10276/6 "2022-01-15T09:52:59Z")

</div>

The line number is not included in the error message to not blow up the canister size too much (although some clever tricks might alleviate that).

So code reading and `Debug.print` debugging (local only) is currently your best bet.

---

<div class="post-metadata">

**Author:** ![NnsDAO](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nnsdao/32/2846_2.png) [@NnsDAO](https://forum.dfinity.org/u/NnsDAO)\
**Post date:** [January 4, 2024, 2:32am UTC](https://forum.dfinity.org/t/reject-text-ic0503-canister-ypg3d-6qaaa-aaaah-aasgq-cai-trapped-explicitly-arithmetic-overflow/10276/7 "2024-01-04T02:32:17Z")

</div>

I’m having the same problem, does anyone know how to fix it?
