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
I cloned a repository to my local machine and deployed the Token Swap program on the Solana devnet, which generated an IDL file. I connected this to a Node.js program using the IDL and program ID. Calling the 'createAMM' function works fine, but calling the 'createPool' function returns some errors. I’ve attached the error details and code below.
Error:Failed to create Pool: SimulateError at AnchorProvider.simulate (C:\BLOCKCHAIN\solana\node_modules\@project-serum\anchor\dist\cjs\provider.js:181:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async MethodsBuilder.simulate [as _simulateFn] (C:\BLOCKCHAIN\solana\node_modules\@project-serum\anchor\dist\cjs\program\namespace\simulate.js:17:24) at async createPool (C:\BLOCKCHAIN\solana\pool.js:182:27) at async C:\BLOCKCHAIN\solana\pool.js:207:9 { simulationResponse: { accounts: null, err: { InstructionError: [Array] }, innerInstructions: null, logs: [ 'Program ComputeBudget111111111111111111111111111111 invoke [1]', 'Program ComputeBudget111111111111111111111111111111 success', 'Program ComputeBudget111111111111111111111111111111 invoke [1]', 'Program ComputeBudget111111111111111111111111111111 success', 'Program H74BkJ2MGWf93BtZ3ya5AKToLWTi66GPMdMYU5Ssvbpx invoke [1]', 'Program log: Instruction: CreatePool', 'Program H74BkJ2MGWf93BtZ3ya5AKToLWTi66GPMdMYU5Ssvbpx consumed 12859 of 499700 compute units', 'Program H74BkJ2MGWf93BtZ3ya5AKToLWTi66GPMdMYU5Ssvbpx failed: Access violation in stack frame 5 at address 0x200005ff8 of size 8' ], replacementBlockhash: null, returnData: null, unitsConsumed: 500000 } } Main execution failed: SimulateError at AnchorProvider.simulate (C:\BLOCKCHAIN\solana\node_modules\@project-serum\anchor\dist\cjs\provider.js:181:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async MethodsBuilder.simulate [as _simulateFn] (C:\BLOCKCHAIN\solana\node_modules\@project-serum\anchor\dist\cjs\program\namespace\simulate.js:17:24) at async createPool (C:\BLOCKCHAIN\solana\pool.js:182:27) at async C:\BLOCKCHAIN\solana\pool.js:207:9 { simulationResponse: { accounts: null, err: { InstructionError: [Array] }, innerInstructions: null, logs: [ 'Program ComputeBudget111111111111111111111111111111 invoke [1]', 'Program ComputeBudget111111111111111111111111111111 success', 'Program ComputeBudget111111111111111111111111111111 invoke [1]', 'Program ComputeBudget111111111111111111111111111111 success', 'Program H74BkJ2MGWf93BtZ3ya5AKToLWTi66GPMdMYU5Ssvbpx invoke [1]', 'Program log: Instruction: CreatePool', 'Program H74BkJ2MGWf93BtZ3ya5AKToLWTi66GPMdMYU5Ssvbpx consumed 12859 of 499700 compute units', 'Program H74BkJ2MGWf93BtZ3ya5AKToLWTi66GPMdMYU5Ssvbpx failed: Access violation in stack frame 5 at address 0x200005ff8 of size 8' ], replacementBlockhash: null, returnData: null, unitsConsumed: 500000 } }
async function checkMint(mint) {
const mintInfo = await connection.getAccountInfo(mint);
if (!mintInfo) throw new Error(Mint ${mint.toString()} does not exist);
console.log(Mint ${mint.toString()} exists);
}
async function ensureATA(mint, authority, payer) {
const ata = await getAssociatedTokenAddress(mint, authority, true);
const accountInfo = await connection.getAccountInfo(ata);
if (!accountInfo) {
console.log(Creating ATA for mint ${mint.toString()});
const tx = await provider.sendAndConfirm(
new Transaction().add(
createAssociatedTokenAccountInstruction(
payer.publicKey,
ata,
authority,
mint,
TOKEN_PROGRAM_ID,
ASSOCIATED_TOKEN_PROGRAM_ID
)
),
[payer]
);
console.log(ATA created: ${ata.toString()}, tx: ${tx});
}
return ata;
}
async function createMints() {
const mintA = await createMint(
connection,
walletKeypair,
walletKeypair.publicKey, // Mint authority
null, // Freeze authority (null means no freeze authority)
6 // Decimals
);
I cloned a repository to my local machine and deployed the Token Swap program on the Solana devnet, which generated an IDL file. I connected this to a Node.js program using the IDL and program ID. Calling the 'createAMM' function works fine, but calling the 'createPool' function returns some errors. I’ve attached the error details and code below.
Error:
Failed to create Pool: SimulateError at AnchorProvider.simulate (C:\BLOCKCHAIN\solana\node_modules\@project-serum\anchor\dist\cjs\provider.js:181:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async MethodsBuilder.simulate [as _simulateFn] (C:\BLOCKCHAIN\solana\node_modules\@project-serum\anchor\dist\cjs\program\namespace\simulate.js:17:24) at async createPool (C:\BLOCKCHAIN\solana\pool.js:182:27) at async C:\BLOCKCHAIN\solana\pool.js:207:9 { simulationResponse: { accounts: null, err: { InstructionError: [Array] }, innerInstructions: null, logs: [ 'Program ComputeBudget111111111111111111111111111111 invoke [1]', 'Program ComputeBudget111111111111111111111111111111 success', 'Program ComputeBudget111111111111111111111111111111 invoke [1]', 'Program ComputeBudget111111111111111111111111111111 success', 'Program H74BkJ2MGWf93BtZ3ya5AKToLWTi66GPMdMYU5Ssvbpx invoke [1]', 'Program log: Instruction: CreatePool', 'Program H74BkJ2MGWf93BtZ3ya5AKToLWTi66GPMdMYU5Ssvbpx consumed 12859 of 499700 compute units', 'Program H74BkJ2MGWf93BtZ3ya5AKToLWTi66GPMdMYU5Ssvbpx failed: Access violation in stack frame 5 at address 0x200005ff8 of size 8' ], replacementBlockhash: null, returnData: null, unitsConsumed: 500000 } } Main execution failed: SimulateError at AnchorProvider.simulate (C:\BLOCKCHAIN\solana\node_modules\@project-serum\anchor\dist\cjs\provider.js:181:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async MethodsBuilder.simulate [as _simulateFn] (C:\BLOCKCHAIN\solana\node_modules\@project-serum\anchor\dist\cjs\program\namespace\simulate.js:17:24) at async createPool (C:\BLOCKCHAIN\solana\pool.js:182:27) at async C:\BLOCKCHAIN\solana\pool.js:207:9 { simulationResponse: { accounts: null, err: { InstructionError: [Array] }, innerInstructions: null, logs: [ 'Program ComputeBudget111111111111111111111111111111 invoke [1]', 'Program ComputeBudget111111111111111111111111111111 success', 'Program ComputeBudget111111111111111111111111111111 invoke [1]', 'Program ComputeBudget111111111111111111111111111111 success', 'Program H74BkJ2MGWf93BtZ3ya5AKToLWTi66GPMdMYU5Ssvbpx invoke [1]', 'Program log: Instruction: CreatePool', 'Program H74BkJ2MGWf93BtZ3ya5AKToLWTi66GPMdMYU5Ssvbpx consumed 12859 of 499700 compute units', 'Program H74BkJ2MGWf93BtZ3ya5AKToLWTi66GPMdMYU5Ssvbpx failed: Access violation in stack frame 5 at address 0x200005ff8 of size 8' ], replacementBlockhash: null, returnData: null, unitsConsumed: 500000 } }
Code: `const { Keypair, PublicKey, SystemProgram, ComputeBudgetProgram, Transaction } = require('@solana/web3.js');
const { Wallet, AnchorProvider, Program } = require('@project-serum/anchor');
const { TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, getAssociatedTokenAddress, createAssociatedTokenAccountInstruction, createMint } = require('@solana/spl-token');
const { clusterApiUrl, Connection } = require('@solana/web3.js');
const idl = require('./idl1.json');
const PRIVATE_KEY_B58 = new Uint8Array(]); // Replace with your private key
const walletKeypair = Keypair.fromSecretKey(PRIVATE_KEY_B58);
const wallet = new Wallet(walletKeypair);
const connection = new Connection(clusterApiUrl('devnet'), 'confirmed');
const provider = new AnchorProvider(connection, wallet, { commitment: 'confirmed', skipPreflight: false });
const programId = new PublicKey('H74BkJ2MGWf93BtZ3ya5AKToLWTi66GPMdMYU5Ssvbpx');
const program = new Program(idl, programId, provider);
const AUTHORITY_SEED = [97, 117, 116, 104, 111, 114, 105, 116, 121];
const LIQUIDITY_SEED = [108, 105, 113, 117, 105, 100, 105, 116, 121];
async function checkMint(mint) {
const mintInfo = await connection.getAccountInfo(mint);
if (!mintInfo) throw new Error(
Mint ${mint.toString()} does not exist
);console.log(
Mint ${mint.toString()} exists
);}
async function ensureATA(mint, authority, payer) {
const ata = await getAssociatedTokenAddress(mint, authority, true);
const accountInfo = await connection.getAccountInfo(ata);
if (!accountInfo) {
console.log(
Creating ATA for mint ${mint.toString()}
);const tx = await provider.sendAndConfirm(
new Transaction().add(
createAssociatedTokenAccountInstruction(
payer.publicKey,
ata,
authority,
mint,
TOKEN_PROGRAM_ID,
ASSOCIATED_TOKEN_PROGRAM_ID
)
),
[payer]
);
console.log(
ATA created: ${ata.toString()}, tx: ${tx}
);}
return ata;
}
async function createMints() {
const mintA = await createMint(
connection,
walletKeypair,
walletKeypair.publicKey, // Mint authority
null, // Freeze authority (null means no freeze authority)
6 // Decimals
);
}
async function createAmm() {
try {
console.log("Starting AMM creation...");
const ammKeypair = Keypair.generate();
const ammId = ammKeypair.publicKey;
const fee = 300;
}
async function createPool(ammAccount, ammId, mintA, mintB) {
try {
console.log("Starting pool creation...");
const balance = await connection.getBalance(walletKeypair.publicKey);
console.log("Payer Balance:", balance / 1e9, "SOL");
}
(async () => {
try {
console.log("Script starting...");
})();`
The text was updated successfully, but these errors were encountered: