简体   繁体   English

交易模拟失败:错误处理指令0:自定义程序错误:0x0

[英]Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0

I am using raydium sdk to add liquidity to the pair, I have created the transaction but whenever it gets approved from the phatom wallet an error occurs which is stated below.我正在使用 raydium sdk 来增加货币对的流动性,我已经创建了交易,但是每当它从 phatom 钱包获得批准时,就会发生如下所述的错误。

Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0
Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL invoke [1]
Program log: Allocate space for the associated token account
Program 11111111111111111111111111111111 invoke [2]
Allocate: account Address { address: 7hLSYuEhn7t1P62n9gpv2aG8peTtLvjSRKqSsk2MXa91, base: None } already in use
Program 11111111111111111111111111111111 failed: custom program error: 0x0
Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 8366 of 200000 compute units
Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL failed: custom program error: 0x0

I need help to fix this as I am unable to identify the issue.我需要帮助来解决这个问题,因为我无法确定问题所在。

Below is my function code which I am using in ReactJS with the help of Raydium SDK.下面是我在 Raydium SDK 的帮助下在 ReactJS 中使用的 function 代码。

 const tokenReq = await solanaConnectionObj.getTokenAccountsByOwner(publicKey, { programId: TOKEN_PROGRAM_ID })
  const parsedTokenAccounts = await solanaConnectionObj.getParsedTokenAccountsByOwner(publicKey, {
    programId: TOKEN_PROGRAM_ID,
  })

  const tokenAccounts = []
  for (let index = 0; index < tokenReq.value.length; index++) {
    const rawResult = SPL_ACCOUNT_LAYOUT.decode(tokenReq.value[index].account.data)
    if (
      rawResult.mint.toString().toLowerCase() === tokenObj0.mint.toString().toLowerCase() ||
      rawResult.mint.toString().toLowerCase() === tokenObj1.mint.toString().toLowerCase() ||
      rawResult.mint.toString().toLowerCase() === RAYDIUM_LP_TOKEN_ACCOUNT.toLowerCase()
    ) {
      tokenAccounts.push({
        accountInfo: rawResult,
        pubkey: publicKey,
      })
    }
  }

  const transactionData = await Liquidity.makeAddLiquidityTransaction({
    poolKeys: RAYDIUM_POOL,
    userKeys: {
      tokenAccounts: tokenAccounts,
      owner: publicKey,
      payer: publicKey,
    },
    fixedSide: 'a',
    amountInB: new TokenAmount(tokenObj1, amount0.toWei().toString()),
    amountInA: new TokenAmount(tokenObj0, amount1.toWei().toString()),
    connection: solanaConnectionObj,
  })

  transactionData.transaction.feePayer = publicKey
  const latestBlockHashResult = await solanaConnectionObj.getRecentBlockhash('confirmed')

  transactionData.transaction.recentBlockhash = latestBlockHashResult.blockhash

  const signedTxs = await signTransaction(transactionData.transaction)
  const txids = await solanaConnectionObj.sendRawTransaction(signedTxs.serialize())

  return transactionData

It's hard to give a full answer without knowing more details about the makeAddLiquidityTransaction endpoint, but the error you're seeing is:如果不了解有关makeAddLiquidityTransaction端点的更多详细信息,很难给出完整的答案,但您看到的错误是:

Allocate: account Address { address: 7hLSYuEhn7t1P62n9gpv2aG8peTtLvjSRKqSsk2MXa91, base: None } already in use

during the invocation of the Associated Token Account program, which creates new token accounts for users.在调用关联令牌帐户程序期间,该程序为用户创建新的令牌帐户。

In your case, the error says that the account is already in use, so the transaction contains an unnecessary call to create the associated token account.在您的情况下,错误表明该帐户已在使用中,因此该交易包含创建关联令牌帐户的不必要调用。 This may be a bug in the Raydium SDK, or the RAYDIUM_LP_TOKEN_ACCOUNT address may be incorrect, causing the SDK to think you don't have the proper LP token account.这可能是 Raydium SDK 中的 bug,或者RAYDIUM_LP_TOKEN_ACCOUNT地址不正确,导致 SDK 认为您没有正确的 LP 令牌帐户。 You can hack around this by removing that first instruction if needed.如果需要,您可以通过删除第一条指令来解决这个问题。

More background for the associated-token-account program at https://spl.solana.com/associated-token-account有关关联令牌帐户计划的更多背景信息,请访问https://spl.solana.com/associated-token-account

Transaction simulation failed errors (in ethereum too) happens when the contract code logic is broken.当合约代码逻辑被破坏时,交易模拟失败错误(在以太坊中也是如此)发生。 You either pass the wrong arguments to the function call on the client side (for example it requires string but you pass a number) or on the client side you are calling functions the wrong way (ake sure you check the api of client side packages)您要么将错误的 arguments 传递给客户端的 function 调用(例如,它需要字符串但您传递了一个数字),要么在客户端以错误的方式调用函数(确保检查客户端包的 api)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:请求的纹理大小 [0x0] 无效 - Error: Requested texture size [0x0] is invalid 错误:处理事务时出现 VM 异常:还原 - Error : VM Exception while processing transaction: revert 请求的纹理大小 [0x0] 无效。 我在浏览器中加载图像时出错 - Requested texture size [0x0] is invalid. error when i am loading image in browser 错误:调用还原异常; 处理事务时出现 VM 异常: - Error: call revert exception; VM Exception while processing transaction: SendTransactionError:发送交易失败:交易模拟失败:尝试借记账户,但没有发现先前贷记的记录 - SendTransactionError: failed to send transaction: Transaction simulation failed: Attempt to debit an account but found no record of a prior credit 无法从客户端调用链码:处理事务时出错。 错误:需要 PEM 编码的证书 - unable to invoke chaincode from client : Error processing transaction. Error: PEM encoded certificate is required 尝试签署交易时出现 Assertion.failed 错误 - Got Assertion.failed error while trying to sign a transaction 字体真棒 0x0 - Font awesome 0x0 处理路线时出现Ember错误:列出断言失败 - Ember Error while processing route: listing Assertion Failed mup 部署错误 - x 启动 Meteor:失败 - mup deploy error - x Start Meteor: FAILED
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM