1

When running anchor test on my solana program it complains that the IDL is missing the metadata.address field. But when I add it, it disappears again after running anchor test. My program built fine.

Also, the field "metadata" gives an error: "Object literal may only specify known properties, and '"metadata"' does not exist in type LossHarvester"

I also tried adding it then running anchor deploy as per this post: Anchor IDL address missing from json

export const IDL: LossHarvester = {
  "version": "0.1.0",
  "name": "loss_harvester",
  "metadata": {
    "address": "[PROGRAM_PUB_KEY]"
  },
...rest of code

Beginning of my program:

#[program]
pub mod loss_harvester {
    use super::*;

    pub fn initialize(ctx: Context<Initialize>) -> Result<()> {

Am I missing something here? Using anchor 0.29 with Solana 1.18.1. Something to note is that I started out with the hello-world template and renamed everything to loss-harvester.

3 Answers 3

1

SOLVED. I forgot to update the program name in one of the fields in Cargo.toml

0

Recently, I had the same error but it was related to something else (the fix you mentioned was not applicable for me)

I was upgrading program from anchor version 0.29.0 to 0.30.1. I had to add

[features]
idl-build = ["anchor-lang/idl-build"]

to the Cargo.toml for the upgrade.

But then when running anchor test I got the same error as is in the title. I figured that I did not update my typescript dependencies. In my yarn.lock there was a dependency for @coral-xyz/anchor@^0.29.0, which is not matching with the upgraded anchor version. I removed the whole yarn.lock file and run yarn add @coral-xyz/anchor@^0.30.1. This also convenietly added all the other dependencies for typescript tests.

So to sum it up, if you came across this error, make sure that your test dependecies match those defined for your program.

-1

export const IDL: LossHarvester = { "version": "0.1.0", "name": "loss_harvester", "metadata": { "address": "[PROGRAM_PUB_KEY]" }, ...rest of code #[program] pub mod loss_harvester { use super::*;

pub fn initialize(ctx: Context<Initialize>) -> Result<()> {

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.