Write a multi-step Solana transaction once, store it on chain, and let anyone run it again with new inputs.
Not audited. Ballista is on mainnet, but no third party has audited the program or the SDKs. Details
import { ASSOCIATED_TOKEN_PROGRAM_ADDRESS_BYTES, SYSTEM_PROGRAM_ADDRESS_BYTES, TOKEN_PROGRAM_ADDRESS_BYTES, account, defineTemplate, ensureAssociatedTokenAccount,} from '@jac0xb/ballista';const createIfMissing = defineTemplate({ accounts: { // The programs it calls, pinned to their real addresses. ataProgram: { executable: true, address: ASSOCIATED_TOKEN_PROGRAM_ADDRESS_BYTES, }, tokenProgram: { executable: true, address: TOKEN_PROGRAM_ADDRESS_BYTES, }, systemProgram: { executable: true, address: SYSTEM_PROGRAM_ADDRESS_BYTES, }, // The accounts the caller passes in. mint: { owner: TOKEN_PROGRAM_ADDRESS_BYTES, minDataLength: 82 }, payer: { signer: true, writable: true }, wallet: {}, ata: { writable: true }, }, steps: [ // Calls Create only while the token account is still empty. ensureAssociatedTokenAccount({ associatedTokenProgram: account.fixed('ataProgram'), payer: account.fixed('payer'), associatedTokenAccount: account.fixed('ata'), owner: account.fixed('wallet'), mint: account.fixed('mint'), systemProgram: account.fixed('systemProgram'), tokenProgram: account.fixed('tokenProgram'), }), ],});