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:
"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 :
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):
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:
dfx identity use default
export LEDGER_ACC=$(dfx ledger account-id)
Deploy the ledger canister to your network by running the following line:
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