# Local ledger canister failed to call send\_dfx command

**URL:** <https://forum.dfinity.org/t/local-ledger-canister-failed-to-call-send-dfx-command/16806>\
**Category:** Command Line Tools\
**Tags:** candid\
**Created:** [November 23, 2022, 3:31pm UTC](https://forum.dfinity.org/t/local-ledger-canister-failed-to-call-send-dfx-command/16806 "2022-11-23T15:31:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaesharma](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jaesharma/32/7297_2.png) [@jaesharma](https://forum.dfinity.org/u/jaesharma)\
**Post date:** [November 23, 2022, 3:31pm UTC](https://forum.dfinity.org/t/local-ledger-canister-failed-to-call-send-dfx-command/16806/1 "2022-11-23T15:31:19Z")

</div>

i have setup ledger canister using dfinity’s official guide, followed instructions from [here](https://internetcomputer.org/docs/current/developer-docs/integrations/ledger/ledger-local-setup/)

after setup i tried this command:

> `dfx canister call custom-ledger account_balance_dfx '(record { account = "'$LEDGER_ACC'" })'`

got response:

> `(record { e8s = 100_000_000_000 : nat64 })`

so i’m assuming custom ledger canister was setup properly.

i got stuck at dfx\_transfer command, i’m using this command:

> `dfx canister call custom-ledger send_dfx '(record {memo = 1234; amount = record { e8s=10_000_000 }; fee = record { e8s=10_000 }; to = "'$USER_ACC'"; created_at_time = null })'`

& getting response:

> `Error: Failed update call. Caused by: Failed update call. The Replica returned an error: code 5, message: "canister trapped: EvalTrapError region:0x51693-0x51695 "canister trapped explicitly: Panicked at 'Deserialization Failed: \"Fail to decode argument 0 from table0 to record {\\n to : text;\\n fee : record { e8s : nat64 };\\n memo : nat64;\\n from_subaccount : opt vec nat8;\\n created_at_time : opt record { timestamp_nanos : nat64 };\\n amount : record { e8s : nat64 };\\n}\"', /ic/rs/rust_canisters/dfn_core/src/endpoint.rs:123:41""`

USER\_ACC here is just principal of another identity, this is the exact value:

> `fuddf-sqzfl-yvosv-7gw22-77y5x-nzj3y-fve3j-mvcr7-wa7x2-e3tnp-nae`

what am i doing wrong here? & is there any other documentation for ref. of cli commands & their formats?!  
thanks for help in advance.

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [November 23, 2022, 5:22pm UTC](https://forum.dfinity.org/t/local-ledger-canister-failed-to-call-send-dfx-command/16806/2 "2022-11-23T17:22:10Z")

</div>

I think you’re missing the field `from_subaccount` in your call arguments

---

<div class="post-metadata">

**Author:** ![jaesharma](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jaesharma/32/7297_2.png) [@jaesharma](https://forum.dfinity.org/u/jaesharma)\
**Post date:** [November 23, 2022, 5:41pm UTC](https://forum.dfinity.org/t/local-ledger-canister-failed-to-call-send-dfx-command/16806/3 "2022-11-23T17:41:23Z")

</div>

![Screenshot from 2022-11-23 23-14-45](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/f/f4c6c1a390afcab9ae00602f285d638bd8613b92.png)

in IDL it is marked as optional, is it required argument here?

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [November 24, 2022, 7:09am UTC](https://forum.dfinity.org/t/local-ledger-canister-failed-to-call-send-dfx-command/16806/4 "2022-11-24T07:09:20Z")

</div>

I think it’s optional to have a value, but it’s required to write it. I.e. the same way you included `created_at_time = null`

---

<div class="post-metadata">

**Author:** ![jaesharma](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jaesharma/32/7297_2.png) [@jaesharma](https://forum.dfinity.org/u/jaesharma)\
**Post date:** [November 24, 2022, 2:22pm UTC](https://forum.dfinity.org/t/local-ledger-canister-failed-to-call-send-dfx-command/16806/5 "2022-11-24T14:22:00Z")

</div>

thanks for the response @Vivienne  
i tried using null with it, still getting error:

> The Replica returned an error: code 5, message: "canister trapped: EvalTrapError region:0x51693-0x51695 “canister trapped explicitly: Panicked at ‘Deserialization Failed: "Fail to decode argument 0 from table0 to record {\n to : text;\n fee : record { e8s : nat64 };\n memo : nat64;\n from\_subaccount : opt vec nat8;\n created\_at\_time : opt record { timestamp\_nanos : nat64 };\n amount : record { e8s : nat64 };\n}"’, /ic/rs/rust\_canisters/dfn\_core/src/endpoint.rs:123:41"”
> 
> ```auto
> 
> ```

not able to figure out what am i missing on this. is format of all argument correct? i’m using this command:

> dfx canister call custom-ledger send\_dfx ‘(record {memo = 1234; amount = record { e8s=10\_000\_000 }; fee = record { e8s=10\_000 }; to = "’$USER\_ACC’"; from\_subaccount = null; created\_at\_time = null })’

and these are the exact values which are getting passed:

> (record {memo = 1234; amount = record { e8s=10\_000\_000 }; fee = record { e8s=10\_000 }; to = “xpfaj-evqin-hf3bt-dxnj6-mb6t6-e6deg-3nigb-ekb6q-f5pjy-7oq3y-bae”; from\_subaccount = null; created\_at\_time = null })

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [November 25, 2022, 8:59am UTC](https://forum.dfinity.org/t/local-ledger-canister-failed-to-call-send-dfx-command/16806/6 "2022-11-25T08:59:13Z")

</div>

I think I got it: Your numerical values get encoded as `int`, but they have to be `nat64`. Your argument has to look like this:

```auto
(record {memo = 1234 : nat64; amount = record { e8s=10_000_000 : nat64}; fee = record { e8s=10_000 : nat64 }; to = "xpfaj-evqin-hf3bt-dxnj6-mb6t6-e6deg-3nigb-ekb6q-f5pjy-7oq3y-bae"; from_subaccount = null; created_at_time = null })

```

Notice the `: nat64` after the numerical values.

To see how it works under the hood:

- get `didc` from the [candid repo](https://github.com/dfinity/candid/)
- `didc encode <your argument string>` shows the value that gets sent over the wire
- `didc decode <output from previous command>` shows how it gets deserialised at the other end
- compare the types you need and the types that you get

Using your actual data:

```auto
❯ didc encode '(record {memo = 1234; amount = record { e8s=10_000_000 }; fee = record { e8s=10_000 }; to = "xpfaj-evqin-hf3bt-dxnj6-mb6t6-e6deg-3nigb-ekb6q-f5pjy-7oq3y-bae"; from_subaccount = null; created_at_time = null })'
4449444c026c06fbca0171c6fcb60201ba89e5c2047ca2de94eb067f82f3f3910c7fd8a38ca80d016c01e0a9b3027c01003f787066616a2d657671696e2d68663362742d64786e6a362d6d623674362d65366465672d336e6967622d656b6236712d6635706a792d376f7133792d62616590ce00d20980ade204

didc decode 4449444c026c06fbca0171c6fcb60201ba89e5c2047ca2de94eb067f82f3f3910c7fd8a38ca80d016c01e0a9b3027c01003f787066616a2d657671696e2d68663362742d64786e6a362d6d623674362d65366465672d336e6967622d656b6236712d6635706a792d376f7133792d62616590ce00d20980ade204
(
  record {
    25_979 = "xpfaj-evqin-hf3bt-dxnj6-mb6t6-e6deg-3nigb-ekb6q-f5pjy-7oq3y-bae";
    5_094_982 = record { 5_035_232 = 10_000 : int };
    1_213_809_850 = 1_234 : int;
    1_835_347_746 = null : null;
    3_258_775_938 = null : null;
    3_573_748_184 = record { 5_035_232 = 10_000_000 : int };
  },
)

```

This is missing the field names (since we didn’t supply the .did file), but we’re only interested in the data types. You can see that it gets decoded as an `int`, but the error message calls for `nat64`. Using the `nat64` annotations:

```auto
❯ didc encode '(record {memo = 1234 : nat64; amount = record { e8s=10_000_000 : nat64}; fee = record { e8s=10_000 : nat64 }; to = "xpfaj-evqin-hf3bt-dxnj6-mb6t6-e6deg-3nigb-ekb6q-f5pjy-7oq3y-bae"; from_subaccount = null; created_at_time = null })'
4449444c026c06fbca0171c6fcb60201ba89e5c20478a2de94eb067f82f3f3910c7fd8a38ca80d016c01e0a9b3027801003f787066616a2d657671696e2d68663362742d64786e6a362d6d623674362d65366465672d336e6967622d656b6236712d6635706a792d376f7133792d6261651027000000000000d2040000000000008096980000000000

❯ didc decode 4449444c026c06fbca0171c6fcb60201ba89e5c20478a2de94eb067f82f3f3910c7fd8a38ca80d016c01e0a9b3027801003f787066616a2d657671696e2d68663362742d64786e6a362d6d623674362d65366465672d336e6967622d656b6236712d6635706a792d376f7133792d6261651027000000000000d2040000000000008096980000000000
(
  record {
    25_979 = "xpfaj-evqin-hf3bt-dxnj6-mb6t6-e6deg-3nigb-ekb6q-f5pjy-7oq3y-bae";
    5_094_982 = record { 5_035_232 = 10_000 : nat64 };
    1_213_809_850 = 1_234 : nat64;
    1_835_347_746 = null : null;
    3_258_775_938 = null : null;
    3_573_748_184 = record { 5_035_232 = 10_000_000 : nat64 };
  },
)

```

now the types match 🥳

---

<div class="post-metadata">

**Author:** ![jaesharma](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jaesharma/32/7297_2.png) [@jaesharma](https://forum.dfinity.org/u/jaesharma)\
**Post date:** [November 25, 2022, 11:01am UTC](https://forum.dfinity.org/t/local-ledger-canister-failed-to-call-send-dfx-command/16806/7 "2022-11-25T11:01:43Z")

</div>

@Vivienne does not seem to work in my case. still getting `Deserialization error`.  
tried encoding my input with didc, i’m getting this when decoded again:

```bash
(
  record {
    25_979 = "xpfaj-evqin-hf3bt-dxnj6-mb6t6-e6deg-3nigb-ekb6q-f5pjy-7oq3y-bae";
    5_094_982 = record { 5_035_232 = 10_000 : nat64 };
    1_213_809_850 = 1_234 : nat64;
    1_835_347_746 = null : null;
    3_258_775_938 = null : null;
    3_573_748_184 = record { 5_035_232 = 10_000_000 : nat64 };
  },
)

```

i tried same input what you have posted hard-coded as argument, still getting same error.

```bash
dfx canister call custom-ledger send_dfx '(record { memo = 1234 : nat64; amount = record { e8s=10_000_000 : nat64; }; fee = record { e8s=10_000 : nat64; }; to = "xpfaj-evqin-hf3bt-dxnj6-mb6t6-e6deg-3nigb-ekb6q-f5pjy-7oq3y-bae"; from_subaccount = null; created_at_time = null })'

```

got this error:

```auto
The Replica returned an error: code 5, message: "canister trapped: EvalTrapError region:0x51693-0x51695 "canister trapped explicitly: Panicked at 'Deserialization Failed: \"Fail to decode argument 0 from table0 to record {\\n to : text;\\n fee : record { e8s : nat64 };\\n memo : nat64;\\n from_subaccount : opt vec nat8;\\n created_at_time : opt record { timestamp_nanos : nat64 };\\n amount : record { e8s : nat64 };\\n}\"', /ic/rs/rust_canisters/dfn_core/src/endpoint.rs:123:41""

```

not sure but could it be possible the `"to"` address is causing this error.  
current `"to"` address i’m using here is: `dfx identity get-principal`  
is this supposed to be any account address or something?

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [November 25, 2022, 12:24pm UTC](https://forum.dfinity.org/t/local-ledger-canister-failed-to-call-send-dfx-command/16806/8 "2022-11-25T12:24:53Z")

</div>

Ah, right, sorry for not noticing this earlier. Ledger accounts are not principals. `dfx ledger account-id` and its many options can help you construct some valid ledger accounts.

If you need more info on generating account identifiers I can recommend this topic: [Error exchanging ICP for cycles](https://forum.dfinity.org/t/error-exchanging-icp-for-cycles/16645)
