mpl-token-metadata
mpl-token-metadata copied to clipboard
createCreateMetadataAccountV3Instruction is missing
I am trying to use the function createCreateMetadataAccountV3Instruction to create an instruction. But I am getting the below error when importing to my Next.js project. The version I am using is the latest. But when I searched for the function in the current Github repo, this function did exist.
"@metaplex-foundation/mpl-token-metadata": "^3.2.1",
'"@metaplex-foundation/mpl-token-metadata"' has no exported member named 'createCreateMetadataAccountV3Instruction'. Did you mean 'CreateMetadataAccountV3InstructionData'?
yea. me too
Same
Hey @y0unghe @rosselpha @y4my4my4m where did you find this and Why do you assume that there should be a function like this?
createCreateMetadataAccountV3Instruction is a type, not a function. The function for it would be createMetadataAccountV3.
If you actually want to directly use that instruction you could use
import {
createMetadataAccountV3,
mplTokenMetadata,
} from "@metaplex-foundation/mpl-token-metadata";
import { none } from "@metaplex-foundation/umi";
const createMetadataAccountV3Ix = createMetadataAccountV3(umi, {
mint: mint.publicKey,
mintAuthority: umi.identity,
isMutable: true,
collectionDetails: none(),
data: {
name: "myToken",
uri: "https://arweave.net/7BzVsHRrEH0ldNOCCM4_E00BiAYuJP_EQiqvcEYz3YY",
symbol: "MT",
sellerFeeBasisPoints: 0,
creators: none(),
collection: none(),
uses: none(),
},
}).getInstructions()
We highly recommend to use the createV1 wrapper though:
import { createV1, mplTokenMetadata, TokenStandard } from "@metaplex-foundation/mpl-token-metadata";
import {
percentAmount,
} from "@metaplex-foundation/umi";
const createV1Ix = createV1(umi, {
mint: mint.publicKey,
authority: umi.identity,
name: "My NFT",
uri: "https://arweave.net/7BzVsHRrEH0ldNOCCM4_E00BiAYuJP_EQiqvcEYz3YY",
sellerFeeBasisPoints: percentAmount(5.5),
tokenStandard: TokenStandard.Fungible,
}).getInstructions()
or, depending on what kind of token you want to create there are Create Helpers that requires even less input. For example createFungible:
await createFungible(umi, {
mint,
name: "myToken",
uri: "https://arweave.net/7BzVsHRrEH0ldNOCCM4_E00BiAYuJP_EQiqvcEYz3YY",
sellerFeeBasisPoints: percentAmount(0),
decimals: tokenAmount.decimals,
})
I find this from https://github.com/solana-developers/pirate-bootcamp/blob/main/quest-1/scripts/3.createTokenWithMetadata.ts#L121 And https://www.youtube.com/watch?v=0P8JeL3TURU&t=1529s
Also the official doc recommend using V2 version. https://solana.com/developers/courses/tokens-and-nfts/token-program#make-some-token-metadata
Do you have any examples about how to use createMetadataAccountV3 without using umi ?
If you are using the same packages as the package.json of the pirate-bootcamp suggests (which is very outdated) it should be working fine. The Solana.com docs you sent recommends to use package version 2 - which does not require Umi.
Personally i would absolutely recommend to follow our docs in the developer hub on how to use umi and how to create Metadata.
If you don't want to interact with umi more than needed this could work (untested code):
import {
createMetadataAccountV3,
mplTokenMetadata,
} from "@metaplex-foundation/mpl-token-metadata";
import { none, createNoopSigner} from "@metaplex-foundation/umi";
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults'
import { toWeb3JsInstruction } from '@metaplex-foundation/umi-web3js-adapters';
const umi = createUmi('https://api.devnet.solana.com').use(mplTokenMetadata())
const createMetadataAccountV3Ix = createMetadataAccountV3(umi, {
mint: mint.publicKey,
mintAuthority: createNoopSigner(<your signing wallet pubkey>),
isMutable: true,
collectionDetails: none(),
data: {
name: "myToken",
uri: "https://arweave.net/7BzVsHRrEH0ldNOCCM4_E00BiAYuJP_EQiqvcEYz3YY",
symbol: "MT",
sellerFeeBasisPoints: 0,
creators: none(),
collection: none(),
uses: none(),
},
}).getInstructions()
const web3jsinstruction = toWeb3JsInstruction(createMetadataAccountV3Ix)
Isn't there a way to do this with just web3.js and the mpl-token-metadata package? Do we have to use umi?
"@metaplex-foundation/mpl-token-metadata": "^2.13.0", this version solve the error
i found this article to be very useful :
https://www.quicknode.com/guides/solana-development/spl-tokens/how-to-create-a-fungible-spl-token-with-the-new-metaplex-token-standard#run-your-code
If you are using the same packages as the package.json of the pirate-bootcamp suggests (which is very outdated) it should be working fine. The Solana.com docs you sent recommends to use package version 2 - which does not require Umi.
Personally i would absolutely recommend to follow our docs in the developer hub on how to use umi and how to create Metadata.
If you don't want to interact with umi more than needed this could work (untested code):
import { createMetadataAccountV3, mplTokenMetadata, } from "@metaplex-foundation/mpl-token-metadata"; import { none, createNoopSigner} from "@metaplex-foundation/umi"; import { createUmi } from '@metaplex-foundation/umi-bundle-defaults' import { toWeb3JsInstruction } from '@metaplex-foundation/umi-web3js-adapters';
const umi = createUmi('https://api.devnet.solana.com').use(mplTokenMetadata())
const createMetadataAccountV3Ix = createMetadataAccountV3(umi, { mint: mint.publicKey, mintAuthority: createNoopSigner(
), isMutable: true, collectionDetails: none(), data: { name: "myToken", uri: "https://arweave.net/7BzVsHRrEH0ldNOCCM4_E00BiAYuJP_EQiqvcEYz3YY", symbol: "MT", sellerFeeBasisPoints: 0, creators: none(), collection: none(), uses: none(), }, }).getInstructions() const web3jsinstruction = toWeb3JsInstruction(createMetadataAccountV3Ix)
The getInstructions() method returns an array of instructions (Instruction[]), but toWeb3JsInstruction expects a single Instruction. Here's the corrected code:
import {
createMetadataAccountV3,
mplTokenMetadata,
} from '@metaplex-foundation/mpl-token-metadata';
import { none, createNoopSigner, publicKey } from '@metaplex-foundation/umi';
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { toWeb3JsInstruction } from '@metaplex-foundation/umi-web3js-adapters';
const umi = createUmi('https://api.devnet.solana.com').use(mplTokenMetadata());
const createMetadataAccountV3Ix = createMetadataAccountV3(umi, {
mint: publicKey(mint.publicKey),
mintAuthority: createNoopSigner('<your signing wallet pubkey>'),
isMutable: true,
collectionDetails: none(),
data: {
name: 'myToken',
uri: 'https://arweave.net/7BzVsHRrEH0ldNOCCM4_E00BiAYuJP_EQiqvcEYz3YY',
symbol: 'MT',
sellerFeeBasisPoints: 0,
creators: none(),
collection: none(),
uses: none(),
},
}).getInstructions();
const web3JsIxs = createMetadataAccountV3Ix.map(toWeb3JsInstruction);