2

Does anyone have a TS file that I can have that creates a metadata pointer for a token where the address is already known.

Almost every exampel I find also creates the token, but I need it to just create the metadata.

Thank you in advance.

1 Answer 1

1

The metadata pointer must be initialized before the base mint is initialized, so it's not possible to add the pointer afterwards.

It's a bit tougher to digest, but there's an example doing it in the JS tests at https://github.com/solana-labs/solana-program-library/blob/8c177be2916da6f81a506c99f17e41e1f7c99d77/token/js/test/e2e-2022/metadataPointer.test.ts#L33:

        mint = Keypair.generate();
        metadataAddress = PublicKey.unique();

        const mintLen = getMintLen(EXTENSIONS);
        const lamports = await connection.getMinimumBalanceForRentExemption(mintLen);

        const transaction = new Transaction().add(
            SystemProgram.createAccount({
                fromPubkey: payer.publicKey,
                newAccountPubkey: mint.publicKey,
                space: mintLen,
                lamports,
                programId: TEST_PROGRAM_ID,
            }),
            createInitializeMetadataPointerInstruction(
                mint.publicKey,
                mintAuthority.publicKey,
                metadataAddress,
                TEST_PROGRAM_ID
            ),
            createInitializeMintInstruction(
                mint.publicKey,
                TEST_TOKEN_DECIMALS,
                mintAuthority.publicKey,
                null,
                TEST_PROGRAM_ID
            )
        );

        await sendAndConfirmTransaction(connection, transaction, [payer, mint], undefined);

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.