Git Product home page Git Product logo

Comments (5)

buffalojoec avatar buffalojoec commented on July 20, 2024 1

You're allocating too much data before initializing the mint. Calling getMintLen three times will allocate space for the base mint three times, as well as the extensions.

const mintSpace = getMintLen([
    ExtensionType.MetadataPointer,
    ExtensionType.TransferFeeConfig,
    ExtensionType.PermanentDelegate,
]);

from solana-program-library.

buffalojoec avatar buffalojoec commented on July 20, 2024

You'll need to provide some more information in order to determine if this is a bug with any SPL libraries!
Please provide your code to reproduce the issue.

from solana-program-library.

kasuba97 avatar kasuba97 commented on July 20, 2024
// type spaces
const mintSpace =
  getMintLen([ExtensionType.MetadataPointer]) +
  getMintLen([ExtensionType.TransferFeeConfig]) +
  getMintLen([ExtensionType.PermanentDelegate]);

const metadataSpace = TYPE_SIZE + LENGTH_SIZE + pack(metadata).length;

const lamports = await connection.getMinimumBalanceForRentExemption(
  mintSpace + metadataSpace,
  "confirmed"
);

const createAccountIx = SystemProgram.createAccount({
  fromPubkey: payer.publicKey,
  newAccountPubkey: mint.publicKey,
  space: mintSpace,
  lamports,
  programId: TOKEN_2022_PROGRAM_ID,
});

const initializeMetadataPointerIx = createInitializeMetadataPointerInstruction(
  mint.publicKey,
  mintAuthority.publicKey,
  mint.publicKey,
  TOKEN_2022_PROGRAM_ID
);

const initializeTransferFeesConfigIx =
  createInitializeTransferFeeConfigInstruction(
    mint.publicKey,
    transferFeeConfigAuthority.publicKey,
    withdrawWithheldAuthority.publicKey,
    50,
    BigInt(5000),
    TOKEN_2022_PROGRAM_ID
  );

const initializePermanentDelegationIx =
  createInitializePermanentDelegateInstruction(
    mint.publicKey,
    permanentDelegationAuthority.publicKey,
    TOKEN_2022_PROGRAM_ID
  );
const initializeMintIx = createInitializeMintInstruction(
  mint.publicKey,
  6,
  mintAuthority.publicKey,
  subzero.publicKey,
  TOKEN_2022_PROGRAM_ID
);

const initializeMetadataIx = createInitializeInstruction({
  programId: TOKEN_2022_PROGRAM_ID,
  metadata: mint.publicKey,
  updateAuthority: updataMetadataAuthority.publicKey,
  name: metadata.name,
  mint: mint.publicKey,
  mintAuthority: mintAuthority.publicKey,
  symbol: metadata.symbol,
  uri: metadata.uri,
});

const updateMetadataIx = createUpdateFieldInstruction({
  updateAuthority: updataMetadataAuthority.publicKey,
  metadata: mint.publicKey,
  programId: TOKEN_2022_PROGRAM_ID,
  field: metadata.additionalMetadata[0][0],
  value: metadata.additionalMetadata[0][1],
});

const transaction = new Transaction().add(
  createAccountIx,
  initializeMetadataPointerIx,
  initializeTransferFeesConfigIx,
  initializePermanentDelegationIx,
  initializeMintIx,
  //
  initializeMetadataIx,
  updateMetadataIx
);

try {
  const txHash = await sendAndConfirmTransaction(connection, transaction, [
    payer,
    updataMetadataAuthority,
    mint,
    mintAuthority,
  ]);
  console.log(`https://solscan.io/tx/${txHash}?cluster=devnet`);
} catch (err) {
  console.log("error: ", err);
}

from solana-program-library.

kasuba97 avatar kasuba97 commented on July 20, 2024

@buffalojoec
this the code that recreates the error

from solana-program-library.

github-actions avatar github-actions commented on July 20, 2024

Hi @kasuba97,

Thanks for your question!

We want to make sure to keep signal strong in the GitHub issue tracker โ€“ to make sure that it remains the best place to track issues that affect the development of Solana itself.

Questions like yours deserve a purpose-built Q&A forum. Unless there exists evidence that this is a bug with Solana itself, please post your question to the Solana Stack Exchange using this link: https://solana.stackexchange.com/questions/ask


This automated message is a result of having added the โ€˜questionโ€™ tag.

from solana-program-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.