Skip to main content
edited title
Link

Is there a way to batch together spl creation-token sdk transactions?

Source Link

Is there a way to batch together spl creation transactions?

I have a program that is creating a mint account, the associated token account, the meta data account. Right now I'm just testing it out without a frontend, but eventually I want to batch them all together into one transaction. The reason why is because I also want to make function callers pay a fee to a certain address. I have the following functions from the @solana/spl-token library, how can I modify them all to be added to the Web3.js Transaction class?

Here's what I have for the two I couldn't figure out:

    const transactionSignature = await token.mintTo(
        connection,
        payer,
        mint,
        destination,
        authority,
        amount
    )

    const tokenAccount = await token.createAssociatedTokenAccount(connection, payer, mint, owner)

Is it good practice to just have separate transactions? In this case, paying the fee would come first. If not, how can I bundle these two and send them together as transactions? I see that the second transaction depends on the mint variable I've never done them separate before so I'm not sure how unconventional it would really be