Solana
The Solana
class from @moonup/moon-api
provides a convenient way to interact with the Solana blockchain. This API allows you to perform various operations related to Solana accounts and transactions.
Here's a detailed documentation for the Solana
class:
Initialization
To use the Solana
class, you need to create an instance of it with a configured HttpClient
. The HttpClient
is responsible for making HTTP requests to the Solana API.
Here's an example of how to create an instance of the Solana
class:
Class: Solana
Methods
createSolanaAccount(data: SolanaInput, params?: RequestParams)
This method is used to create a new Solana account.
Parameters:
data
: An object containing the input data for creating the Solana account.params
: Optional request parameters.
Returns: A promise that resolves to the data of the created Solana account.
Example:
getSolanaAccount(accountName: string, params?: RequestParams)
This method is used to get the details of a specific Solana account.
Parameters:
accountName
: The name of the Solana account.params
: Optional request parameters.
Returns: A promise that resolves to the data of the specified Solana account.
Example:
listSolanaAccounts(params?: RequestParams)
This method is used to list all Solana accounts.
Parameters:
params
: Optional request parameters.
Returns: A promise that resolves to the data of all Solana accounts.
Example:
multiSignSolanaTransaction(accountName: string, data: SolanaSignTransactionInput, params?: RequestParams)
This method is used to multi-sign a Solana transaction for a specific account.
Parameters:
accountName
: The name of the Solana account.data
: An object containing the input data for multi-signing the Solana transaction.params
: Optional request parameters.
Returns: A promise that resolves to the data of the multi-signed Solana transaction.
Example:
signSolanaTransaction(accountName: string, data: SolanaSignTransactionInput, params?: RequestParams)
This method is used to sign a Solana transaction for a specific account.
Parameters:
accountName
: The name of the Solana account.data
: An object containing the input data for signing the Solana transaction.params
: Optional request parameters.
Returns: A promise that resolves to the data of the signed Solana transaction.
Example:
transferSolanaTransaction(accountName: string, data: SolanaTransactionInput, params?: RequestParams)
This method is used to transfer SOL from a specific Solana account.
Parameters:
accountName
: The name of the Solana account.data
: An object containing the input data for the transfer.params
: Optional request parameters.
Returns: A promise that resolves to the data of the transfer transaction.
Example:
transferTokensSignSolanaTransaction(accountName: string, data: SolanaTransactionInput, params?: RequestParams)
This method is used to transfer tokens from a specific Solana account.
Parameters:
accountName
: The name of the Solana account.data
: An object containing the input data for the token transfer.params
: Optional request parameters.
Returns: A promise that resolves to the data of the token transfer transaction.
Example:
Usage
To use the Solana
class, you need to create an instance of it with a configured HttpClient
. The HttpClient
is responsible for making HTTP requests to the Solana API.
You can then use the solana
instance to call the various methods of the Solana
class. Make sure to handle any potential errors that may occur during the API calls using try-catch
blocks.
Last updated