Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: function createCreateMetadataAccountV2Instruction of the library @mpl-token-metadata version 2.13.0 has no createMetadataAccountArgsV2 parameter compared to version 2.8.6 #1157

Open
TanLocc opened this issue Aug 31, 2023 · 1 comment
Labels

Comments

@TanLocc
Copy link

TanLocc commented Aug 31, 2023

Which package is this bug report for?

auction-house

Which Type of Package is this bug report for?

Rust Contract

Issue description

This is the code to create Token Metadata:
`import { initializeKeypair } from "./initializeKeypair"
import * as web3 from "@solana/web3.js"
import * as token from "@solana/spl-token"
import {
Metaplex,
keypairIdentity,
bundlrStorage,
toMetaplexFile,
} from "@metaplex-foundation/js"
import {
DataV2,
createCreateMetadataAccountV2Instruction,
createUpdateMetadataAccountV2Instruction,
} from "@metaplex-foundation/mpl-token-metadata"
import * as fs from "fs"

async function createTokenMetadata(
connection: web3.Connection,
metaplex: Metaplex,
mint: web3.PublicKey,
user: web3.Keypair,
name: string,
symbol: string,
description: string
) {
// file to buffer
const buffer = fs.readFileSync("assets/hobby.png")

// buffer to metaplex file
const file = toMetaplexFile(buffer, "hobby.png")

// upload image and get image uri
const imageUri = await metaplex.storage().upload(file)
console.log("image uri:", imageUri)

// upload metadata and get metadata uri (off chain metadata)
const { uri } = await metaplex
.nfts()
.uploadMetadata({
name: name,
description: description,
image: imageUri,
})

console.log("metadata uri:", uri)

// get metadata account address
const metadataPDA = metaplex.nfts().pdas().metadata({mint})

// onchain metadata format
const tokenMetadata = {
name: name,
symbol: symbol,
uri: uri,
sellerFeeBasisPoints: 0,
creators: null,
collection: null,
uses: null,
} as DataV2

// transaction to create metadata account
const transaction = new web3.Transaction().add(
createCreateMetadataAccountV2Instruction(
{
metadata: metadataPDA,
mint: mint,
mintAuthority: user.publicKey,
payer: user.publicKey,
updateAuthority: user.publicKey,
},
{
createMetadataAccountArgsV2: {
data: tokenMetadata,
isMutable: true,
},
}
)
)

// send transaction
const transactionSignature = await web3.sendAndConfirmTransaction(
connection,
transaction,
[user]
)

console.log(
Create Metadata Account: https://explorer.solana.com/tx/${transactionSignature}?cluster=devnet
)
}

async function main() {
const connection = new web3.Connection(web3.clusterApiUrl("devnet"))
const user = await initializeKeypair(connection)
console.log("PublicKey:", user.publicKey.toBase58())

const MINT_ADDRESS = "2N967jALpfz2jHLhLuNRQDmAvoUBTTAV1PcAsmQiw9RW"

// metaplex setup
const metaplex = Metaplex.make(connection)
.use(keypairIdentity(user))
.use(
bundlrStorage({
address: "https://devnet.bundlr.network",
providerUrl: "https://api.devnet.solana.com",
timeout: 60000,
})
)

// Calling the token
await createTokenMetadata(
connection,
metaplex,
new web3.PublicKey(MINT_ADDRESS),
user,
"Hobby", // Token name - REPLACE THIS WITH YOURS
"HOB", // Token symbol - REPLACE THIS WITH YOURS
"Whoever holds the token will have a chance to become a happy person" // Token description - REPLACE THIS WITH YOURS
)
}

main()
.then(() => {
console.log("Finished successfully")
process.exit(0)
})
.catch((error) => {
console.log(error)
process.exit(1)
})`

createCreateMetadataAccountV2Instruction function of library @mpl-token-metadata version 2.13.0 does not have parameter createMetadataAccountArgsV2 then how token descriptions such as symbol, uri, name are passed to save in PDA metadata.

Relevant log output

No response

Priority this issue should have

Medium (should be fixed soon)

@TanLocc TanLocc added the bug label Aug 31, 2023
@ajaysathvik
Copy link

I have the same bug with the import of createUpdateMetadataAccountV2Instruction

The error is :

@metaplex-foundation/mpl-token-metadata has no exported member named createUpdateMetadataAccountV2Instruction.
Did you mean 'UpdateMetadataAccountV2InstructionData'?ts(2724)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants