ICP index local deployment

Is there documentation available for deploying and configuring the ICP ledger index canister locally?

I’ve created a script to deploy it locally in Juno (https://github.com/buildwithjuno/juno/blob/feat/index-canister/scripts/index.sh), but transactions aren’t syncing. :thinking:

Are the 55 ICP your balance on your local replica or on mainnet?

Everything local.

I send my local canister 55 ICP from the ledger with an ICRC-1 transfer using this script.

https://github.com/buildwithjuno/juno/blob/main/scripts/ledger.transfer.mjs

As far as I can see, there are two ledgers deployed, one being the one that comes with dfx (dfx ledger …) and then the ledger you deploy manually (dfx canister ledger …), are you sure you are indexing the correct one?

I would say yes, I use this script to deploy the index canister https://github.com/buildwithjuno/juno/blob/feat/index-canister/scripts/index.sh

#!/usr/bin/env bash

IC_VERSION=6223a38cfae726e9cc83db9ae27f35ca979dd0d8
curl -o index.wasm.gz "https://download.dfinity.systems/ic/$IC_VERSION/canisters/ic-icp-index-canister.wasm.gz"
gunzip index.wasm.gz
curl -o index.did "https://raw.githubusercontent.com/dfinity/ic/$IC_VERSION/rs/rosetta-api/icp_ledger/index/index.did"

LEDGER_ID=$(dfx canister id ledger)

dfx deploy index --specified-id r7inp-6aaaa-aaaaa-aaabq-cai --argument '(record {ledger_id = principal"'${LEDGER_ID}'";})'

What does it say when you call the status endpoint of the index canister? Is it the same as that of your locally deployed ledger?
Also, which canister ID did you transfer ICP to? I believe you mixed up the two ledgers since you named them identically.
Try and name them differently, --specified-id does not guarentee the id will be set, it will just try to set. It is possible that the existing ledger and your locally deployed one have the same ledger id.

I can printout the canister IDs this evening but, I’m almost sure ledger ID I’m using are correct but, will printout.

I transfer to a canister ID because it’s the user’s canister that holds ICP. It’s correct, that’s deployed and bullet proofed on mainnet.

@NikolasHai here the IDs:

❯ ./scripts/index.sh
Deploying: index
Creating canisters...
Creating canister index...
index canister created with canister id: r7inp-6aaaa-aaaaa-aaabq-cai
Building canisters...
Installing canisters...
Installing code for canister index, with canister ID r7inp-6aaaa-aaaaa-aaabq-cai
Deployed canisters.
URLs:
  Frontend canister via browser
    frontend: http://127.0.0.1:8000/?canisterId=bw4dl-smaaa-aaaaa-qaacq-cai
  Backend canister via Candid interface:
    cmc: http://127.0.0.1:8000/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=rkp4c-7iaaa-aaaaa-aaaca-cai
    console: http://127.0.0.1:8000/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=cokmz-oiaaa-aaaal-aby6q-cai
    index: http://127.0.0.1:8000/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=r7inp-6aaaa-aaaaa-aaabq-cai
    internet_identity: http://127.0.0.1:8000/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=rrkah-fqaaa-aaaaa-aaaaq-cai
    ledger: http://127.0.0.1:8000/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=ryjl3-tyaaa-aaaaa-aaaba-cai
    mission_control: http://127.0.0.1:8000/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=bd3sg-teaaa-aaaaa-qaaba-cai
    observatory: http://127.0.0.1:8000/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=klbfr-lqaaa-aaaak-qbwsa-cai
    orbiter: http://127.0.0.1:8000/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=br5f7-7uaaa-aaaaa-qaaca-cai
    satellite: http://127.0.0.1:8000/?canisterId=bnz7o-iuaaa-aaaaa-qaaaa-cai&id=be2us-64aaa-aaaaa-qaabq-cai

i.e.

ledger: ryjl3-tyaaa-aaaaa-aaaba-cai
index: r7inp-6aaaa-aaaaa-aaabq-cai

in addition output of dfx canister id ledger equals:

❯ dfx canister id ledger
ryjl3-tyaaa-aaaaa-aaaba-cai

So canister IDs are correct in my opinion.

I also double checked the JavaScript code, I correctly query the index canister ID equals to r7inp-6aaaa-aaaaa-aaabq-cai

I just ran through the deploying and synching of a locally set-up ledger and index successfully and I can see there are a couple of issues with your code.

  1. You are using an old IC Version: Try the lates → Releases - ICP Dashboard
  2. The file ledger.private.did does no longer exist, just use the public one
  3. The guide for local ledger setup you are following has been updated since you last used it. Here is the new guide: Ledger local setup | Internet Computer
  4. The arguments to deploy the ledger are wrong. You can see in the guide it is now a variant instead of just a record.

If you change these things it should work. Let me know what your result is.

2 Likes

There now also exists a tutorial on how to deploy and connect the ICP index canister locally:

3 Likes

Thanks @NikolasHai , it worked out :white_check_mark:

Upgrading the ledger to a most recent version probably fixed the issue.

Currently got that in a branch but if anoyone is interested, here two bash scripts to deploy ledger and index: