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

Adding priority fees to collection creation so there's higher chance of landing on chain #548

Open
martincik opened this issue Mar 27, 2024 · 2 comments

Comments

@martincik
Copy link

Hi team,

This is our code for creating collection with Metaplex foundation JS SDK:

export async function createCollection(
  metaplex: Metaplex,
  metadataUri: string,
  name: string,
  sellerFee: number,
  creators: { address: PublicKey; share: number }[],
  symbol?: string
) {
  const createNftBuilder = await metaplex.nfts().builders().create({
    uri: metadataUri,
    name: name,
    sellerFeeBasisPoints: sellerFee,
    symbol: symbol,
    creators: creators,
    isCollection: true,
    tokenStandard: TokenStandard.NonFungible,
  })

  const resp = await createNftBuilder.sendAndConfirm(metaplex, {
    commitment: "finalized",
  })
  return {
    mint: resp.mintAddress,
    metadataAccount: resp.metadataAddress,
    masterEditionAccount: resp.masterEditionAddress,
  }
}

How do I modify this code to add priority fees for Solana? Thanks.

@johnsonchau-bulb
Copy link

Bumping this as recent solana network congestion is causing minting to be very flaky

@mileshiroo
Copy link

i had this problem too and this worked for me as a temporary fix to add a priority fee. changed RpcClient.cjs and RpcClient.mjs in dist/ and patched with npx patch-package


  async sendTransaction(transaction, sendOptions = {}, signers = []) {    
    const prepared = await this.prepareTransaction(transaction, signers);

    const modifyComputeUnits = ComputeBudgetProgram.setComputeUnitLimit({ 
      units: 1000000  
    });
    
    const addPriorityFee = ComputeBudgetProgram.setComputeUnitPrice({ 
      microLamports: 1 
    });

    prepared.transaction.instructions.unshift(addPriorityFee);
    prepared.transaction.instructions.unshift(modifyComputeUnits);

    transaction = prepared.transaction;
    signers = prepared.signers;
    const defaultFeePayer = this.getDefaultFeePayer();
    if (!transaction.feePayer && defaultFeePayer) {
      transaction.feePayer = defaultFeePayer.publicKey;
      signers = [defaultFeePayer, ...signers];
    }
    transaction = await this.signTransaction(transaction, signers);
    const rawTransaction = transaction.serialize();
    try {
      return await this.metaplex.connection.sendRawTransaction(rawTransaction, sendOptions);
    } catch (error) {
      throw this.parseProgramError(error, transaction);
    }
  }

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

No branches or pull requests

3 participants