-
Notifications
You must be signed in to change notification settings - Fork 528
Description
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)