Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solana/programs

Package Overview
Dependencies
Maintainers
14
Versions
935
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/programs

Helpers for defining programs and resolving program errors

  • 2.0.0-canary-20241028084938
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.6K
decreased by-18.8%
Maintainers
14
Weekly downloads
 
Created
Source

npm npm-downloads semantic-release
code-style-prettier

@solana/programs

This package contains helpers for identifying custom program errors. It can be used standalone, but it is also exported as part of the Solana JavaScript SDK @solana/web3.js@rc.

Functions

isProgramError()

This function takes any error — typically caused by a transaction failure — and identifies whether it is a custom program error from the provided program address. It takes the following parameters:

  • The error to identify.
  • The transactionMessage object that failed to execute. Since the RPC response only provide the index of the failed instruction, we need the transaction message to access its program address.
  • The programAddress of the program from which the error is expected.
  • Optionally, the expected error code of the custom program error. When provided, the function will also check that the custom program error code matches the given value.
try {
    // Send and confirm your transaction.
} catch (error) {
    if (isProgramError(error, transactionMessage, myProgramAddress, 42)) {
        // Handle custom program error 42 from this program.
    } else if (isProgramError(error, transactionMessage, myProgramAddress)) {
        // Handle all other custom program errors from this program.
    } else {
        throw error;
    }
}

Keywords

FAQs

Package last updated on 28 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc