程序返回错误:自定义程序错误:solana上的0x179D

发布于 2025-02-08 14:38:32 字数 258 浏览 1 评论 0原文

之间的通信中有下一个错误

嗨,Dex Exchange和Phantom Wallet #1未知程序指令

程序日志:free_supply:14100789713994 程序日志:自定义程序错误:0x179D 程序ZO1GGZTUKMY5BYNDVT5MTVEZXZF2FALTBKKMVGUHUQK消耗了41719个1400000计算单元 程序返回错误:自定义程序错误:0x179d

可能导致问题是什么?

Hi got next error in communication between dex exchange and phantom wallet

#1 Unknown program instruction

Program log: free_supply: 14100789713994
Program log: Custom program error: 0x179d
Program Zo1ggzTUKMY5bYnDvT5mtVeZxzf2FaLTbKkmvGUhUQk consumed 41719 of 1400000 compute units
Program returned error: custom program error: 0x179d

what might cause the issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吾性傲以野 2025-02-15 14:38:32

当您看到自定义程序错误...时,它表明交易中的程序指令失败。 0x179d是程序的 code ,它可能是唯一的错误代码,通常是在此处的Rust Enum的索引(变体)程序error.rs

例如:

pub enum SampleError {
    InvalidInstruction,
    DeserializationFailure,
    AlreadyInitializedState,
    KeyNotFoundInAccount,
    KeyAlreadyExists,
    InsufficientFundsForTransaction,
    UnknownError,
}

因此,您可能可以通过0x0通过0x6看到一个错误代码。程序还可以以其他方式分配错误代码。

为了使您知道与代码关联的错误是您可以在程序源代码中查找错误。如果您要调用的程序不是开源的...您可以尝试联系程序的所有者,以获取有关代码的更多信息。

When you see custom program error... it indicates that a program instruction in your transaction failed. The 0x179d is the program's code which may be a unique error code, often times it is an index (variant) of a Rust enum in the program error.rs.

For example:

pub enum SampleError {
    InvalidInstruction,
    DeserializationFailure,
    AlreadyInitializedState,
    KeyNotFoundInAccount,
    KeyAlreadyExists,
    InsufficientFundsForTransaction,
    UnknownError,
}

So here, you could possibly see an error code of 0x0 through 0x6. A program may also assign the error code in some other way.

In order for you to know what the error associated to the code is you can either look up the error in the programs source code. If the program you are calling is not open source... you can try to contact the owner of the program to get more information about the code.

暗藏城府 2025-02-15 14:38:32

弗兰克的答案非常好,但是我想提供一些其他代码来展示如何转换错误。

下面的示例是针对 spl代币库,如果您使用的是其他链程序,请替换该程序的错误errors.rs.rs

// Some SPL transactions will give
// errors like 'custom program error: 0x1'
// These are what those errors mean (eg, 1 means "Insufficient funds")

// TODO: fix upstream. The TS SDK should give real errors.

// https://github.com/solana-labs/solana-program-library/blob/master/token/program/src/error.rs
enum customProgramErrors {
  "Lamport balance below rent-exempt threshold",
  "Insufficient funds",
  "Invalid Mint",
  "Account not associated with this Mint",
  "Owner does not match",
  "Fixed supply",
  "Already in use",
  "Invalid number of provided signers",
  "Invalid number of required signers",
  "State is unititialized",
  "Instruction does not support native tokens",
  "Non-native account can only be closed if its balance is zero",
  "Invalid instruction",
  "State is invalid for requested operation",
  "Operation overflowed",
  "Account does not support specified authority type",
  "This token mint cannot freeze accounts",
  "Account is frozen",
  "The provided decimals value different from the Mint decimals",
  "Instruction does not support non-native tokens",
}

:您的错误消息:

export const getABetterErrorMessage = (errorMessage: string) => {
  const customErrorExpression =
    /.*custom program error: 0x(?<errorNumber>[0-9abcdef])/;

  let match = customErrorExpression.exec(errorMessage);
  const errorNumberFound = match?.groups?.errorNumber;
  if (!errorNumberFound) {
    return null;
  }
  // errorNumberFound is a base16 string
  const errorNumber = parseInt(errorNumberFound, 16);
  return customProgramErrors[errorNumber] || null;
};

Frank's answer is excellent, but I wanted to give some additional code to show how to convert the errors.

The example below is for SPL Token Library, if you're using a different on-chain program, substitute the errors from that programs errors.rs:

// Some SPL transactions will give
// errors like 'custom program error: 0x1'
// These are what those errors mean (eg, 1 means "Insufficient funds")

// TODO: fix upstream. The TS SDK should give real errors.

// https://github.com/solana-labs/solana-program-library/blob/master/token/program/src/error.rs
enum customProgramErrors {
  "Lamport balance below rent-exempt threshold",
  "Insufficient funds",
  "Invalid Mint",
  "Account not associated with this Mint",
  "Owner does not match",
  "Fixed supply",
  "Already in use",
  "Invalid number of provided signers",
  "Invalid number of required signers",
  "State is unititialized",
  "Instruction does not support native tokens",
  "Non-native account can only be closed if its balance is zero",
  "Invalid instruction",
  "State is invalid for requested operation",
  "Operation overflowed",
  "Account does not support specified authority type",
  "This token mint cannot freeze accounts",
  "Account is frozen",
  "The provided decimals value different from the Mint decimals",
  "Instruction does not support non-native tokens",
}

And a function to give you good error messages:

export const getABetterErrorMessage = (errorMessage: string) => {
  const customErrorExpression =
    /.*custom program error: 0x(?<errorNumber>[0-9abcdef])/;

  let match = customErrorExpression.exec(errorMessage);
  const errorNumberFound = match?.groups?.errorNumber;
  if (!errorNumberFound) {
    return null;
  }
  // errorNumberFound is a base16 string
  const errorNumber = parseInt(errorNumberFound, 16);
  return customProgramErrors[errorNumber] || null;
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文