1

I run anchor build , and it indeeded generate a sol404.json , but when I run the anchor test it shows /Users/brooke/Desktop/sol404/node_modules/.bin/ts-mocha -p ./tsconfig.json -t 1000000 'tests/**/*.ts' Error: target/idl/sol_404.json doesn't exist. Did you runanchor build? here is my test code

const jellyTokenMintMetadataPDA = await metaplex
    .nfts()
    .pdas()
    .metadata({ mint: JellyTokenMintPDA });

    const usdcTokenMintMetadataPDA = await metaplex
    .nfts()
    .pdas()
    .metadata({ mint: UsdcTokenMintPDA });

    const nftTokenMintMetadataPDA = await metaplex
    .nfts()
    .pdas()
    .metadata({ mint: NftTokenMintPDA });

    const tx = await program.methods
    .createmint(jellymetadata.uri, usdcmetadata.uri, nftmetadata.uri, jellymetadata.name, usdcmetadata.name, nftmetadata.name, jellymetadata.symbol, usdcmetadata.symbol, nftmetadata.symbol)
    .accounts({
      admin: admin.publicKey,
      jellyTokenMint: JellyTokenMintPDA,
      usdcTokenMint: UsdcTokenMintPDA,
      nftMint: NftTokenMintPDA,
      jellyTokenAccount: JellyTokenAccount,
      usdcTokenAccount: UsdcTokenAccount,
      nftTokenAccount: NftTokenAccount,
      jellyMetadataAccount: jellyTokenMintMetadataPDA,
      usdcMetadataAccount: usdcTokenMintMetadataPDA,
      nftMetadataAccount: nftTokenMintMetadataPDA,
      tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID,
    })
    .rpc();
    console.log("Your transaction signature", tx);

here is my anchor.toml

[toolchain]

[features]
seeds = false
skip-lint = false

[programs.localnet]
sol404 = "EzkLoHgcsJ3XCxsTq2a7kmkwAcYh1CGoJtjghCVGescK"

[registry]
url = "https://api.apr.dev"


[provider]
cluster = "Localnet"
wallet = "/Users/b/.config/brooke/solana/id.json"

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

here is my Cargo.toml

[package]
name = "sol404"
version = "0.1.0"
description = "Created with Anchor"
edition = "2021"

[lib]
crate-type = ["cdylib", "lib"]
name = "sol404"

[features]
no-entrypoint = []
no-idl = []
no-log-ix-name = []
cpi = ["no-entrypoint"]
default = []

[dependencies]
anchor-lang = {version = "0.29.0", features = ["init-if-needed"]}
anchor-spl = {version = "0.29.0", features = ["metadata"]}
solana-program = "1.18.11"

any one can help me?

1 Answer 1

3

I assume there will be a discrepancy in naming of your project. You can see the idl is generated to sol404.json and is searched at file sol_404.json by anchor test.

The code of anchor workspace loading is here https://github.com/coral-xyz/anchor/blob/v0.30.0/ts/packages/anchor/src/workspace.ts#L64 The idl path is generated from programName.

You define that program.localnet is with sol404. The programs/sol404/Cargo.toml may use the name sol-404 in name within [lib](?).

I would suggest to change the [programs.localnet] of Anchor.toml file from sol404 to sol_404. Or to unite the naming in some way within the Cargo.toml and Anchor.toml files.

2
  • In the programs/sol404/Cargo.toml , I use the name sol404instead of sol_404, I dunno why the name runanchor test different with the name I use in Cargo.toml & Anchor.toml
    – papi
    Commented Apr 23 at 2:28
  • 1
    Yeap, I'm not sure why this naming mix happens in Anchor neither.
    – chalda
    Commented Apr 23 at 8:01

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.