You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im am trying to launch a token with several buys, but it does not work, because bundingcurve account is not found
Bonding curve after create and buy: null
9atFnGwHDDFeA7Y1r24iV39mTpafXchx6mtXHtQNNYfe: No Account Found
Buy code:
`async createAndBuyWithAdditionalWallets(
creator: Keypair,
mint: Keypair,
createTokenMetadata: CreateTokenMetadata,
buyAmountSol: bigint,
wallet1: { wallet: Keypair; buyAmountSol: bigint }, // First additional wallet for buying
buyWallets: { wallet: Keypair; buyAmountSol: bigint }[], // Additional wallets for buying in parallel
slippageBasisPoints: bigint = 500n,
priorityFees?: PriorityFee,
commitment: Commitment = DEFAULT_COMMITMENT,
finality: Finality = DEFAULT_FINALITY
): Promise<TransactionResult[]> {
try {
// First Transaction: Create and mint the token, and buy with one additional wallet
console.log("Creating token metadata...");
const tokenMetadata = await this.createTokenMetadata(createTokenMetadata);
console.log("Token metadata created.");
console.log("Getting create and mint instructions...");
const createMintTx = await this.getCreateInstructions(
creator.publicKey,
createTokenMetadata.name,
createTokenMetadata.symbol,
tokenMetadata.metadataUri,
mint
);
console.log("Create and mint instructions obtained.");
let transaction1 = new Transaction();
// Increase compute budget
console.log("Setting compute budget...");
const computeBudgetIx1 = ComputeBudgetProgram.setComputeUnitLimit({ units: 500000 });
transaction1.add(computeBudgetIx1);
// Add priority fees if provided
if (priorityFees) {
console.log("Adding priority fees...");
const priorityFeeIx1 = ComputeBudgetProgram.setComputeUnitPrice({ microLamports: priorityFees.unitPrice });
transaction1.add(priorityFeeIx1);
}
transaction1.add(createMintTx);
if (buyAmountSol > 0) {
console.log("Adding buy instructions for the first wallet...");
const globalAccount = await this.getGlobalAccount(commitment);
const buyAmount = globalAccount.getInitialBuyPrice(buyAmountSol);
const buyAmountWithSlippage = calculateWithSlippageBuy(buyAmountSol, slippageBasisPoints);
console.log(`First wallet buyAmount: ${buyAmount.toString()}, buyAmountWithSlippage: ${buyAmountWithSlippage.toString()}`);
const buyTx = await this.getBuyInstructions(
wallet1.wallet.publicKey,
mint.publicKey,
globalAccount.feeRecipient,
buyAmount,
buyAmountWithSlippage
);
transaction1.add(buyTx);
}
// Fetch recent blockhash
console.log("Fetching recent blockhash for first transaction...");
const { blockhash: blockhash1 } = await this.connection.getRecentBlockhash(commitment);
// Set recent blockhash
transaction1.recentBlockhash = blockhash1;
// Set fee payer
transaction1.feePayer = creator.publicKey;
// Sign transaction
console.log("Signing first transaction...");
transaction1.partialSign(creator, mint, wallet1.wallet);
console.log("Sending first transaction...");
const signature1 = await this.connection.sendTransaction(transaction1, [creator, mint, wallet1.wallet], { skipPreflight: false, preflightCommitment: commitment });
console.log("Confirming first transaction...");
await this.connection.confirmTransaction(signature1, finality);
// Fetch the full transaction response
console.log("Fetching first transaction details...");
const transactionResponse1 = await this.connection.getTransaction(signature1, { commitment: finality });
if (transactionResponse1 === null) {
throw new Error('Failed to fetch first transaction response.');
}
const transactionResult1: TransactionResult = {
signature: signature1,
success: true,
results: transactionResponse1 as VersionedTransactionResponse,
};
// Second Step: Send multiple buy transactions in parallel
console.log("Sending multiple buy transactions in parallel...");
const buyTransactions = buyWallets.map(async ({ wallet, buyAmountSol }) => {
if (buyAmountSol > 0) {
let transaction = new Transaction();
const globalAccount = await this.getGlobalAccount(commitment);
const buyAmount = globalAccount.getInitialBuyPrice(buyAmountSol);
const buyAmountWithSlippage = calculateWithSlippageBuy(buyAmountSol, slippageBasisPoints);
console.log(`Wallet ${wallet.publicKey.toBase58()} buyAmount: ${buyAmount.toString()}, buyAmountWithSlippage: ${buyAmountWithSlippage.toString()}`);
const buyTx = await this.getBuyInstructions(
wallet.publicKey,
mint.publicKey,
globalAccount.feeRecipient,
buyAmount,
buyAmountWithSlippage
);
transaction.add(buyTx);
// Fetch recent blockhash
const { blockhash } = await this.connection.getRecentBlockhash(commitment);
// Set recent blockhash and fee payer
transaction.recentBlockhash = blockhash;
transaction.feePayer = wallet.publicKey;
// Sign transaction
transaction.partialSign(wallet);
console.log(`Sending buy transaction for wallet ${wallet.publicKey.toBase58()}...`);
const signature = await this.connection.sendTransaction(transaction, [wallet], { skipPreflight: false, preflightCommitment: commitment });
console.log(`Confirming buy transaction for wallet ${wallet.publicKey.toBase58()}...`);
await this.connection.confirmTransaction(signature, finality);
// Fetch the transaction response
const transactionResponse = await this.connection.getTransaction(signature, { commitment: finality });
if (transactionResponse === null) {
throw new Error(`Failed to fetch transaction response for wallet ${wallet.publicKey.toBase58()}.`);
}
return {
signature: signature,
success: true,
results: transactionResponse as VersionedTransactionResponse,
} as TransactionResult;
}
return undefined;
});
// Wait for all transactions to complete and filter out undefined values
const transactionResults2 = (await Promise.all(buyTransactions)).filter((result): result is TransactionResult => result !== undefined);
// Combine the results
return [transactionResult1, ...transactionResults2];
Im am trying to launch a token with several buys, but it does not work, because bundingcurve account is not found
Bonding curve after create and buy: null
9atFnGwHDDFeA7Y1r24iV39mTpafXchx6mtXHtQNNYfe: No Account Found
Buy code:
`async createAndBuyWithAdditionalWallets(
creator: Keypair,
mint: Keypair,
createTokenMetadata: CreateTokenMetadata,
buyAmountSol: bigint,
wallet1: { wallet: Keypair; buyAmountSol: bigint }, // First additional wallet for buying
buyWallets: { wallet: Keypair; buyAmountSol: bigint }[], // Additional wallets for buying in parallel
slippageBasisPoints: bigint = 500n,
priorityFees?: PriorityFee,
commitment: Commitment = DEFAULT_COMMITMENT,
finality: Finality = DEFAULT_FINALITY
): Promise<TransactionResult[]> {
try {
// First Transaction: Create and mint the token, and buy with one additional wallet
console.log("Creating token metadata...");
const tokenMetadata = await this.createTokenMetadata(createTokenMetadata);
console.log("Token metadata created.");
} catch (error) {
console.error("Error during transaction creation and submission:", error);
return [{
success: false,
error: error,
}];
}
}
`
The text was updated successfully, but these errors were encountered: