Search code examples
solanametaplexphantom-wallet

Metaplex createMetadataAccountV3 How to Populate Context


I'm trying to utilize the @metaplex-foundation/umi library and came across an issue when setting up the context and invoking the createMetadataAccountV3 function:

const umi = require('@metaplex-foundation/umi');

let myContext = umi.createNullContext();
let myTransaction = metaPlex.createMetadataAccountV3(
    myContext,
    CreateMetadataAccountV3Args
);

While attempting the above, I consistently receive the following error:

InterfaceImplementationMissingError: Tried using ProgramRepositoryInterface but no implementation of that interface was found. Make sure an implementation is registered, e.g. via "context.programs = new MyProgramRepository();".

The SDK documentation suggests using:

context.programs = new MyProgramRepository();

However, it's not entirely clear to me how to properly implement this. Could anyone provide guidance on how to correctly populate myContext and address this error?


Solution

  • I found the answer under umi docs.

    Not a fan of umi....but it is what it is.

    https://github.com/metaplex-foundation/umi/blob/main/docs/installation.md

    const myUmi= require('@metaplex-foundation/umi-bundle-defaults');
    
    const umi = myUMI.createUmi('https://api.mainnet-beta.solana.com');
    
    let CreateMetadataAccountV3Args = {
            //accounts
            metadata: metadataAccount,
            mint: polaris_exp_mintKeypair.publicKey,
            mintAuthority: pdaPublicKey,
            payer: feePayerAccount.publicKey,
            updateAuthority: pdaPublicKey,
            // & instruction data
        data: {
          name: "myname",
          symbol: "exp",
          uri: "example_uri.com",
          sellerFeeBasisPoints: 0,
          creators: null,
          collection: null,
          uses: null
        },
        isMutable: true,
        collectionDetails: null,
      }
    
      const umi = myUMI.createUmi('https://api.mainnet-beta.solana.com');
    
      let myTransaction = metaPlex.createMetadataAccountV3(
        umi,
        CreateMetadataAccountV3Args
      )
    
      console.log(myTransaction)