/main.mo:1.1-1.32: import error [M0011], canister alias "ledger" not defined

Looking at your other post, the reason for the error is that you removed the ledger entry from your dfx.json, which is where dfx looks for your canister import. Mainnet canisters outside of your project don’t import the same way (yet), so for now you have to specify the canister id and define the actor interface as per quint’s or this example (in fact it doesn’t actually have to be the whole ledger canister interface, just the methods that you’re calling so the compiler can perform type checking).
Defining the actor type in a separate file is a good approach.

Re the accidentally deploying the ledger issue you’ve faced, as you’ve seen the issue arises because dfx deploy deploys all canisters specified in the dfx.json and for local development the tutorial example has you include the ledger canister here too. One solution, as suggested, is to deploy canisters individually by naming them, eg dfx deploy my_canister, you could do this for each of your app’s canisters and just don’t deploy the ledger canister.

Possibly a better workflow for you Jesse, is to set up the local ledger canister in an entirely separate project, see this post here:

Doing things this way would ensure you only ever have your app’s canisters in your app project, and you can then simply dfx deploy --network ic and only your app’s canisters would be deployed. You would need to call the ledger using a canister id and actor definition as above for both local and mainnet deployment (note the local and mainnet canister ids will be different), but this is a more consistent approach and it separates concerns, which is useful when it comes to testing and deploying, especially if you start to build projects that call multiple other project’s canisters.

4 Likes