1. Could someone explain what the differences are to [programs.localnet], [programs.devnet] and possibly [programs.mainnet-beta] defined in Anchor.toml

The anchor-lang reference for the manifest only mentions programs.localnet

programs.localnet is used during testing on localnet where it's possible to load a program at genesis with the --bpf-program option on solana-test-validator

  1. Why does having two programs.localnet or programs.devnet result in this error
Error: Unable to deserialize config: redefinition of table `programs.localnet` for key `programs.localnet` at line 8 column 1

I am trying to have multiple programs in my Anchor workspace.

1 Answer 1

  1. It just informs anchor what network you will be using to deploy your program. Whether its localnet, devnet, or the mainnet([programs.mainnet])

  2. I believe you should be creating a seperate program directory for each program, and provide the idl for each program to use multiple programs in Anchor workspace. Something like

  • /programs/program1/src/lib.rs
  • /programs/program2/src/lib.rs


  • /programs/program1/target/idl/program1.json
  • /programs/program2/target/idl/program2.json

Then u should have to modify the anchor.toml file to read both the programs.

lib1 = "<program1.keypair>"
idl1 = "<program1.idl>"
lib2 = "<program2.keypair>"
idl2 = "<program2.idl>"

Not entirely sure about whether anchor.toml config notations are correct... but I think this way u can use two programs

  • the anchor new CLI command takes care of the creation.
    – Jimii
    Nov 14, 2023 at 11:00
  • Thats fairly convenient then!
    – toastx
    Nov 14, 2023 at 11:07
  • for the code snippet you shared, will I be using the paths to the idls?
    – Jimii
    Nov 14, 2023 at 11:08
  • 1
    I tried it via anchor now, and I dont think u will need to specify the path, Anchor will do it by itself. But u will have to build both the programs once, for anchor to generate the idl
    – toastx
    Nov 14, 2023 at 11:09
  • Please mark as answered if ur query has been cleared
    – toastx
    Nov 14, 2023 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.