js
js copied to clipboard
Unable to change updateAuthority to an NFT.
Good day!!
I'm creating nfts in the back-end using a proxyWallet that sign all the transactions there.
The process is:
*The user transfer SOL to proxyWallet
*The proxy wallet mint the nfts with that SOL
The problem is, even when the proxy wallet is the one that mints the nfts, I want to change some parameters like the updateAuthority...
https://github.com/metaplex-foundation/js/blob/3d7e45bfe3200d771707a1c4f652a3ba0c98e475/packages/js/src/plugins/nftModule/operations/createNft.ts#L82
The problem is that I have to put a Signer in the updateAuthority:
https://github.com/metaplex-foundation/js/blob/1827aaea479106a966ba026fbc97fe4a78c240c3/packages/js/src/types/Signer.ts#L3
obviously, I supposed that I couldn't create a KeypairSigner because I have no way to access to the privateKey of the user...
How can I create an IdentitySigner using the wallet of the user?
There is some method to make that?
I just want to make something like these:
const { nft } = await metaplex
.nfts()
.create({
updateAuthority: new PublicKey(userWallet)
})
.run();
But I don't know how
The updateAuthority parameters and other parameters such as the mintAuthority should not accept a publicKey data type?
I just want to mint the nfts with the proxy wallet but put some things like the updateAuthority and the mintAuthority using another wallet. In these case the wallet of the user...
Creating a master edition requires the updateAuthority to be a signer: https://github.com/metaplex-foundation/js/blob/6fcb0b6ffe616eb8a30933799b23d7495f80ab24/packages/js/src/plugins/nftModule/operations/createNft.ts#L72-L82
This can be worked around by adding an instruction to transfer the update authority immediately after minting Something like:
--- a/packages/js/src/plugins/nftModule/operations/createNft.ts
+++ b/packages/js/src/plugins/nftModule/operations/createNft.ts
@@ -81,6 +81,13 @@ export type CreateNftInput = {
*/
updateAuthority?: Signer;
+ /**
+ * The account to which the updateAuthority will be transfered to
+ *
+ * @defaultValue `null`
+ */
+ transferUpdateAuthority?: PublicKey;
+
/**
* The authority that is currently allowed to mint new tokens
* for the provided mint account.
@@ -391,6 +398,7 @@ export const createNftBuilder = async (
useNewMint = Keypair.generate(),
payer = metaplex.identity(),
updateAuthority = metaplex.identity(),
+ transferUpdateAuthority = null,
mintAuthority = metaplex.identity(),
tokenOwner = metaplex.identity().publicKey,
} = params;
@@ -414,38 +422,46 @@ export const createNftBuilder = async (
sftBuilder.getContext();
const masterEditionAddress = findMasterEditionV2Pda(mintAddress);
- return (
- TransactionBuilder.make<CreateNftBuilderContext>()
- .setFeePayer(payer)
- .setContext({
- mintAddress,
- metadataAddress,
- masterEditionAddress,
- tokenAddress: tokenAddress as PublicKey,
- })
+ let transactionBuilder = TransactionBuilder.make<CreateNftBuilderContext>()
+ .setFeePayer(payer)
+ .setContext({
+ mintAddress,
+ metadataAddress,
+ masterEditionAddress,
+ tokenAddress: tokenAddress as PublicKey,
+ })
+
+ // Create the mint, the token and the metadata.
+ .add(sftBuilder)
+
+ // Create master edition account (prevents further minting).
+ .add({
+ instruction: createCreateMasterEditionV3Instruction(
+ {
+ edition: masterEditionAddress,
+ mint: mintAddress,
+ updateAuthority: updateAuthority.publicKey,
+ mintAuthority: mintAuthority.publicKey,
+ payer: payer.publicKey,
+ metadata: metadataAddress,
+ },
+ {
+ createMasterEditionArgs: {
+ maxSupply: params.maxSupply === undefined ? 0 : params.maxSupply,
+ },
+ }
+ ),
+ signers: [payer, mintAuthority, updateAuthority],
+ key: params.createMasterEditionInstructionKey ?? 'createMasterEdition',
+ });
- // Create the mint, the token and the metadata.
- .add(sftBuilder)
-
- // Create master edition account (prevents further minting).
- .add({
- instruction: createCreateMasterEditionV3Instruction(
- {
- edition: masterEditionAddress,
- mint: mintAddress,
- updateAuthority: updateAuthority.publicKey,
- mintAuthority: mintAuthority.publicKey,
- payer: payer.publicKey,
- metadata: metadataAddress,
- },
- {
- createMasterEditionArgs: {
- maxSupply: params.maxSupply === undefined ? 0 : params.maxSupply,
- },
- }
- ),
- signers: [payer, mintAuthority, updateAuthority],
- key: params.createMasterEditionInstructionKey ?? 'createMasterEdition',
- })
- );
+ if (transferUpdateAuthority) {
+ const updateMetadataBuilder = await metaplex.nfts().builders().updateNft({
+ updateAuthority,
+ newUpdateAuthority: transferUpdateAuthority,
+ });
+ transactionBuilder.add(updateMetadataBuilder);
+ }
+
+ return transactionBuilder;
};
But another issue is the update authority needs to be a verified creator while creating the metadata: https://github.com/metaplex-foundation/js/blob/6fcb0b6ffe616eb8a30933799b23d7495f80ab24/packages/js/src/plugins/nftModule/operations/createSft.ts#L73-L83
This seems redundant since the update metadata instruction can change the creators to any public keys. Is there a good reason not to allow arbirary public keys as the creators of a metadata account?
Hi there 👋
Would you not be able to create an instance of IdentitySigner and provide your own logic for the signTransaction and signAllTransaction functions?
Hi there wave
Would you not be able to create an instance of
IdentitySignerand provide your own logic for thesignTransactionandsignAllTransactionfunctions?
Can explain me better this comment? Right now to change the update authority I have to do these...
// Instruction to create the nft
const mintTransactionBuilder = await createNftBuilder(metaplex, {
tokenOwner: userWallet,
uri: link,
name: data.name,
sellerFeeBasisPoints: data.seller_fee_basis_points,
})
const mintAddressNft = mintTransactionBuilder.getContext().mintAddress
// Adding instruction to change updateAuthority to the wallet of the user
const updateMetadataBuilder = metaplex.nfts().builders().update({
nftOrSft: {
address: mintAddressNft,
name: data.name,
uri: link,
sellerFeeBasisPoints: data.seller_fee_basis_points,
},
updateAuthority: proxyWallet,
newUpdateAuthority: userWallet
})
mintTransactionBuilder.add(updateMetadataBuilder)
I have to create a separate instruction where I establish the newUpdateAuthority.... I just want be able to make these please...
const mintTransactionBuilder = await createNftBuilder(metaplex, {
tokenOwner: userWallet,
uri: link,
name: data.name,
sellerFeeBasisPoints: data.seller_fee_basis_points,
updateAuthority: proxyWallet,
newUpdateAuthority: userWallet
})
Being newUpdateAuthority a Publickey not a Signer
@lorisleiva
Hi @HereFrank,
Thank you for your question!
We'd like to make sure our GitHub issue tracker remains the best place to manage issues that affect the development of the Metaplex JS SDK itself.
Your question deserves a purpose-built Q&A forum like StackOverflow so it is more searchable and encourages others to contribute to and benefit from the answer.
Unless there exists evidence that this is a bug with the JS SDK itself, would you please post your question to the Solana Stack Exchange using the following link:
https://solana.stackexchange.com/questions/ask?tags=metaplex
If you could please share the link to the newly created question here afterwards, that would be very helpful for anyone following this thread.
This automated message is a result of having added the "question" label.