Say for instance I am building something that interacts with the spl_token program. How do I include this and test this interaction? Do I need to copy and paste the code into the programs directory and update Anchor.toml? Any better way to do this?

1 Answer 1


I assume you mean to test in your local test validator, using anchor test.

You cannot simply copy-paste the spl_token program because it is not an Anchor program.

There are a couple of ways to go about this. Here is one: You can download the program from mainnet and configure Anchor to deploy it as part of your test.

  1. Download the program:
solana program dump --url mainnet-beta TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA token.so
  1. Update Anchor.toml to tell Anchor to deploy the program as part of the test to the local test validator:
address = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
program = "<path to>/token.so"

More info on the Anchor.toml section here: https://www.anchor-lang.com/docs/manifest#test

Now if you run anchor test, the program will be available for invocation.

  • nice... this all makes sense... but what is the .so ending there supposed to signify? Commented Jul 22, 2022 at 13:54
  • also, is there an easy place for me to find these addresses (for token etc)? Commented Jul 22, 2022 at 13:55
  • 1
    .so is the file extension for shared library binaries like the ones Rust produces. For your use case, the extension doesn't really matter. You can name that file whatever you want.
    – sohrab
    Commented Jul 22, 2022 at 14:01
  • 1
    Most Solana explorers let you search for those. I just searched for "token" in Solscan or SolanaFM (can't remember which)
    – sohrab
    Commented Jul 22, 2022 at 14:01
  • Sorry to be a bother but would it be possible to include in the answer some information on how to create an instance of token in a test environment? still not sure how this should be handled. Commented Jul 22, 2022 at 14:17

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.