# Issues working with the ledger canister

**URL:** <https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138>\
**Category:** Getting Started\
**Created:** [April 14, 2022, 3:21am UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138 "2022-04-14T03:21:29Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![w0whi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/w0whi/32/5213_2.png) [@w0whi](https://forum.dfinity.org/u/w0whi)\
**Post date:** [April 14, 2022, 3:21am UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/1 "2022-04-14T03:21:29Z")

</div>

I’m currently working with the Ledger canister pulled from Aviate Labs’ Github ([GitHub - aviate-labs/icp-canister: A canister that holds ICP](https://github.com/aviate-labs/icp-canister)). Everything has deployed just fine, but when trying to call the balance() function using Candid, I get the error:

Call was rejected:  
Request ID: 510f2809dd1ce281299974c80c9fcde367c654cfc17419c8d7acd1269a5ebbf1  
Reject code:   
Reject text: IC0302: Canister ryjl3-tyaaa-aaaaa-aaaba-cai has no update method ‘account\_balance’

The error message leads me to believe that it is unable to access the ‘account\_balance’ function from the Ledger.mo module it’s calling from. Any ideas as to what I’m doing wrong? Below is a look at the code for the balance() function I’m trying to call:

 ![2022-04-13 (5)](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/e/e887a87295ed5cf519bc3dabdfef22354640867e.png)

And this would be the code for the actor I’m importing from the Ledger.mo module:

 ![2022-04-13 (6)](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/1/1aad250f776954945514987f0874049f082fe4f1.png)

---

<div class="post-metadata">

**Author:** ![domwoe](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/domwoe/32/5165_2.png) [@domwoe](https://forum.dfinity.org/u/domwoe)\
**Post date:** [April 14, 2022, 7:10am UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/2 "2022-04-14T07:10:57Z")

</div>

It seems that you try to call the `account_balance` function from the NNS ledger which is marked as a query function (See [Canlista](https://k7gat-daaaa-aaaae-qaahq-cai.raw.ic0.app/listing/nns-ledger-10244/ryjl3-tyaaa-aaaaa-aaaba-cai) ). Query functions can be only called from agents not from other canisters. That would explain why you get this error that there’s "no update method `account_balance`".

---

<div class="post-metadata">

**Author:** ![Jesse](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jesse/32/37836_2.png) [@Jesse](https://forum.dfinity.org/u/Jesse)\
**Post date:** [April 19, 2022, 5:06pm UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/3 "2022-04-19T17:06:44Z")

</div>

i used the same example and i was actually able to get it to work. I’m curious as to why its not working for you here. did you ever find a solution?

---

<div class="post-metadata">

**Author:** ![w0whi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/w0whi/32/5213_2.png) [@w0whi](https://forum.dfinity.org/u/w0whi)\
**Post date:** [April 19, 2022, 6:46pm UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/4 "2022-04-19T18:46:15Z")

</div>

This is the error i get when trying to deploy the ledger canister locally using these parameters, but i’m not quite sure what it’s referencing. Everything is properly configured in dfx.json(“Candid” value set to “ledger.private.did”). I used the same AccountIdentifier in my “initial\_values” as i did for “minting\_account”. That shouldn’t be a problem right?

 ![2022-04-19](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/c/c855f8331822878af6e8f3372f98b91a0af626c1.png)

---

<div class="post-metadata">

**Author:** ![Jesse](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jesse/32/37836_2.png) [@Jesse](https://forum.dfinity.org/u/Jesse)\
**Post date:** [April 19, 2022, 6:56pm UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/5 "2022-04-19T18:56:22Z")

</div>

Getting the ledger canister running locally was a bit of a hassle for me the first time. I was eventually able to get it running locally buy conducting these steps:

delete the /package-lock.json file,  
delete the /node\_modules file,  
delete the /dist file,  
delete the /.dfx file,  
delete the /src/declarations file

add the follow property to the “canisters” object in the dfx.json file:

```auto
"ledger": {
      "type": "custom",
      "wasm": "ledger.wasm",
      "candid": "ledger.public.did"
    },

```

change the `"candid": "ledger.public.did"` line of the dfx.json file so that it reads `"candid": "ledger.private.did"`

start local replica(if its not already started) by running the following line :

```auto
dfx start --background

```

Create a new identity that will work as a minting account by running the following lines(note, `dfx identity new minter` may error out as a result of this identity already existing. if it does, thats okay. carry onto the next commands):

```auto
dfx identity new minter
dfx identity use minter
export MINT_ACC=$(dfx ledger account-id)

```

Switch back to your default identity and record its ledger account identifier by running the following lines:

```auto
dfx identity use default
export LEDGER_ACC=$(dfx ledger account-id)

```

Deploy the ledger canister to your network by running the following line:

```auto
dfx deploy ledger --argument '(record {minting_account = "'${MINT_ACC}'"; initial_values = vec { record { "'${LEDGER_ACC}'"; record { e8s=100_000_000_000 } }; }; send_whitelist = vec {}})'

```

change the “candid”: “ledger.private.did” line of the dfx.json file back so that it reads “candid”: “ledger.public.did” again.

Take the ledger canister-id and set it as the value of the CANISTER\_ID variable in the /ledger.mo file.

run the following commands in the Digital-Time-Capsule terminal:

npm i

then, in a new terminal:  
//note: dont run `dfx deploy` by itself, because that’ll redeploy another ledger canister for you as well.  
// run the commands exactly like so:

dfx deploy dtc

dfx deploy dtc\_assets

then:

npm start

---

<div class="post-metadata">

**Author:** ![w0whi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/w0whi/32/5213_2.png) [@w0whi](https://forum.dfinity.org/u/w0whi)\
**Post date:** [April 19, 2022, 7:19pm UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/6 "2022-04-19T19:19:04Z")

</div>

Thanks for the help man. The first error was just a small syntax error in my argument, but what I didn’t know was to change the CANISTER\_ID variable in Ledger.mo to that of my ledger. Seems to be working just fine now.

---

<div class="post-metadata">

**Author:** ![w0whi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/w0whi/32/5213_2.png) [@w0whi](https://forum.dfinity.org/u/w0whi)\
**Post date:** [April 19, 2022, 8:41pm UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/7 "2022-04-19T20:41:05Z")

</div>

When calling for the balance of my canister, I still get 0, even though i set my canister to have a preset balance in my “initial\_values”. Here are the parameters I used:

dfx deploy ledger --argument “record { minting\_account=“6da4509fa7e69430d1c1aa1d43f281dafe412f30eeeabe5c6ade86378b26135d”;  
initial\_values=vec {record{“ryjl3-tyaaa-aaaaa-aaaba-cai”; record{e8s = 10000000 : nat64}}};  
max\_message\_size\_bytes= null;  
transaction\_window= null;  
archive\_options= null; send\_whitelist= vec {}; }”

 ![2022-04-19 (1)](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/b/b934c1d725a5136bb0f67cdb8ae1d3610d55d367.png)

---

<div class="post-metadata">

**Author:** ![Jesse](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jesse/32/37836_2.png) [@Jesse](https://forum.dfinity.org/u/Jesse)\
**Post date:** [April 19, 2022, 8:42pm UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/8 "2022-04-19T20:42:50Z")

</div>

put this command in the terminal to mint coins to your LEDGER\_ACC wallet:

```auto
dfx canister call ledger transfer 'record {memo = 1234; amount = record { e8s=10_000_000_000 }; fee = record { e8s=10_000 }; from_subaccount = null; to = '$(python3 -c 'print("vec{" + ";".join([str(b) for b in bytes.fromhex("'$LEDGER_ACC'")]) + "}")')'; created_at_time = null }'

```

---

<div class="post-metadata">

**Author:** ![w0whi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/w0whi/32/5213_2.png) [@w0whi](https://forum.dfinity.org/u/w0whi)\
**Post date:** [April 19, 2022, 9:02pm UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/9 "2022-04-19T21:02:15Z")

</div>

Strange that it doesn’t pick that command up

 ![2022-04-19 (2)](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/3/32d90cd7bb509112117992ada1cf4af93692b46a.png)

---

<div class="post-metadata">

**Author:** ![Jesse](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jesse/32/37836_2.png) [@Jesse](https://forum.dfinity.org/u/Jesse)\
**Post date:** [April 19, 2022, 9:04pm UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/10 "2022-04-19T21:04:17Z")

</div>

I think you’re missing the `'` at the end.

---

<div class="post-metadata">

**Author:** ![w0whi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/w0whi/32/5213_2.png) [@w0whi](https://forum.dfinity.org/u/w0whi)\
**Post date:** [April 19, 2022, 9:35pm UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/11 "2022-04-19T21:35:00Z")

</div>

> [@Jesse](#):
>
> `'$(python3 -c 'print("vec{" + ";".join([str(b) for b in bytes.fromhex("'$LEDGER_ACC'")]) + "}")')'`

Fixed it. My last question is regarding checking the account\_balance of the LEDGER\_ACC using the command line. It requires the the account ID be converted to a blob. Would this just have to be executed within the canister and copy/pasted? Or is there a quicker way to go about this?

---

<div class="post-metadata">

**Author:** ![Jesse](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jesse/32/37836_2.png) [@Jesse](https://forum.dfinity.org/u/Jesse)\
**Post date:** [April 19, 2022, 9:35pm UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/12 "2022-04-19T21:35:55Z")

</div>

run this command to check the balance:

```auto
dfx canister call ledger account_balance '(record { account = '$(python3 -c 'print("vec{" + ";".join([str(b) for b in bytes.fromhex("'$LEDGER_ACC'")]) + "}")')' })'

```

---

<div class="post-metadata">

**Author:** ![w0whi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/w0whi/32/5213_2.png) [@w0whi](https://forum.dfinity.org/u/w0whi)\
**Post date:** [April 20, 2022, 6:27pm UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/13 "2022-04-20T18:27:17Z")

</div>

When sending ICP to another canister using the command line, where would the account ID of the destination canister be derived from?

---

<div class="post-metadata">

**Author:** ![successaje](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/successaje/32/7924_2.png) [@successaje](https://forum.dfinity.org/u/successaje)\
**Post date:** [December 24, 2022, 4:37pm UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/15 "2022-12-24T16:37:05Z")

</div>

![Screenshot 2022-12-18 at 12.37.12](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/f/ff1b0c517198d0a2ef8db02c9b12c6bdff63f581.png)  
I have been stuck with this for a while and even followed your steps and still got this error.

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [December 24, 2022, 8:24pm UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/16 "2022-12-24T20:24:46Z")

</div>

What parameters are you passing to DFX? Can we see the command you ran? The errors telling you what the problem is. You need to make sure that your arguments match expected signature. It’s possible if those have changed since the tutorial was written.

---

<div class="post-metadata">

**Author:** ![successaje](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/successaje/32/7924_2.png) [@successaje](https://forum.dfinity.org/u/successaje)\
**Post date:** [December 25, 2022, 11:50am UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/17 "2022-12-25T11:50:04Z")

</div>

dfx deploy ledger --argument ‘(record {minting\_account = "’${MINT\_ACC}‘"; initial\_values = vec { record { "’${LEDGER\_ACC}‘"; record { e8s=100\_000\_000\_000 } }; }; send\_whitelist = vec {}})’  
i use this to deploy the ledger canister.

dfx deploy canister\_name --argument=“(principal "r7inp-6aaaa-aaaaa-aaabq-cai", record { "supply" = 100 : nat16; "name" = "canister\_name"; })”  
i use this to deploy my canister

---

<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:** [January 4, 2023, 9:41am UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/18 "2023-01-04T09:41:13Z")

</div>

> [@successaje](#):
>
> –argument=“(principal “r7inp-6aaaa-aaaaa-aaabq-cai”, record { "su

You’re terminating your string too early.

```auto
 --argument=“(principal "r7inp-6aaaa-aaaaa-aaabq-cai", record { "su
            ^ start ^end ^start ^end 

```

If you use `"` to delimit your string, you’ll have to escape double quotes like this: `\"` or use single quotes (if you don’t use string interpolation, like you’re not using in this example)

---

<div class="post-metadata">

**Author:** ![successaje](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/successaje/32/7924_2.png) [@successaje](https://forum.dfinity.org/u/successaje)\
**Post date:** [January 8, 2023, 12:04pm UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/19 "2023-01-08T12:04:45Z")

</div>

Ohh yes, it was a pseudo command. Even after using the correct one i still get the error.

dfx deploy canister\_name --argument=“(principal "r7inp-6aaaa-aaaaa-aaabq-cai", record { "supply" = 100 : nat16; "name" = "canister\_name"; })”

---

<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:** [January 9, 2023, 7:24am UTC](https://forum.dfinity.org/t/issues-working-with-the-ledger-canister/12138/20 "2023-01-09T07:24:57Z")

</div>

IDK if it’s a display error / Discourse being annoying, but I see the same error in the command you posted
