Struct SolscanAPI

Source
pub struct SolscanAPI { /* private fields */ }
Expand description

SolscanAPI is a struct that contains a String for the SolscanURL and a Client which is the instance.

Properties:

A doc comment. A doc comment. A doc comment.

  • base_url: The base URL for the Solscan API.
  • client: This is the HTTP client that will be used to make requests to the Solscan API.

Implementations§

Source§

impl SolscanAPI

Implementation of the struct called SolscanAPI.

Source

pub fn new() -> SolscanAPI

It creates a new instance of the SolscanAPI struct.

Returns:

A new instance of the SolscanAPI struct.

Source

pub fn new_with_url(solscan_url: String) -> SolscanAPI

This function creates a new instance of the SolscanAPI struct, which is used to make custom requests to the Solscan API (mostly useful for mockups)

Arguments:

  • solscan_url: The URL of the Solscan API.

Returns:

A new instance of the SolscanAPI struct.

Source

pub async fn ping_status( &self, endpoint: Option<String>, ) -> Result<StatusCode, Error>

It checks the status of the endpoint.

Arguments:

  • endpoint: The endpoint to ping. If none is provided, the base url will be used.

Returns:

A Result<StatusCode, Error>

Source

pub async fn get_block_last( &self, limit: Option<i64>, ) -> Result<Vec<BlockResult>, SolscanError>

It gets the last block

Arguments:

  • limit: The number of blocks to return.

Returns:

A Result<Vec, SolscanError>

Source

pub async fn get_block_transactions( &self, block: i64, offset: Option<i64>, limit: Option<i64>, ) -> Result<Vec<TransactionLast>, SolscanError>

It gets the transactions for a block.

Arguments:

  • block: The block number to get transactions for.
  • offset: The offset of the first transaction to return.
  • limit: The number of transactions to return.

Returns:

A Result<Vec, SolscanError>

Source

pub async fn get_block_block( &self, block: i64, ) -> Result<BlockResult, SolscanError>

It gets the block information for a given block number.

Arguments:

  • block: The block number you want to query

Returns:

A Result<BlockResult, SolscanError>

Source

pub async fn get_transaction_last( &self, limit: Option<i64>, ) -> Result<Vec<TransactionLast>, SolscanError>

It gets the last transactions from the blockchain.

Arguments:

  • limit: The number of transactions to return.

Returns:

A Result<Vec, SolscanError>

Source

pub async fn get_transaction( &self, signature: &str, ) -> Result<Transaction, SolscanError>

It fetches a transaction from the blockchain.

Arguments:

  • signature: The transaction hash

Returns:

A Result<Transaction, SolscanError>

Source

pub async fn get_account_tokens( &self, account: &str, ) -> Result<Vec<Token>, SolscanError>

It fetches the tokens associated with an account.

Arguments:

  • account: The address of the account you want to get the tokens for.

Returns:

A Result<Vec, SolscanError>

Source

pub async fn get_account_transactions( &self, account: &str, before_hash: Option<String>, limit: Option<i64>, ) -> Result<Vec<TransactionListItem>, SolscanError>

It gets the transactions for a given account.

Arguments:

  • account: The address of the account you want to get the transactions for.
  • before_hash: The hash of the transaction you want to start from.
  • limit: The number of transactions to return.

Returns:

A Result<Vec, SolscanError>

Source

pub async fn get_account_stake_accounts( &self, account: &str, ) -> Result<Vec<Token>, SolscanError>

It returns a list of accounts that have staked to the given account.

Arguments:

  • account: The account address to query

Returns:

A Result<Vec, SolscanError>

Source

pub async fn get_account_spl_transfer( &self, account: &str, form_time: Option<u64>, to_time: Option<u64>, offset: Option<i64>, limit: Option<i64>, ) -> Result<SplTransfer, SolscanError>

It fetches the account spl transfer data from the solscan api.

Arguments:

  • account: The account address to query
  • form_time: The start time of the query.
  • to_time: The time to end the search at.
  • offset: The offset of the first result to return.
  • limit: The number of results to return.

Returns:

A Result<SplTransfer, SolscanError>

Source

pub async fn get_account_sol_transfer( &self, account: &str, form_time: Option<u64>, to_time: Option<u64>, offset: Option<i64>, limit: Option<i64>, ) -> Result<SolTransferList, SolscanError>

It gets the SOL transfers for a given account.

Arguments:

  • account: The account address to query
  • form_time: The start time of the query.
  • to_time: The timestamp of the last block you want to include in the results.
  • offset: The offset of the first result to return.
  • limit: The number of results to return.

Returns:

A Result<SolTransferList, SolscanError>

Source

pub async fn get_account_account( &self, account: &str, ) -> Result<AccountInfo, SolscanError>

It fetches the account information of the given account.

Arguments:

  • account: The account address to query

Returns:

A Result<AccountInfo, SolscanError>

Source

pub async fn get_token_holders( &self, account: &str, offset: Option<i64>, limit: Option<i64>, ) -> Result<TokenHolders, SolscanError>

It returns a list of token holders for a given token address.

Arguments:

  • account: The address of the token contract
  • offset: The offset of the first result to return.
  • limit: The number of results to return.

Returns:

A Result<TokenHolders, SolscanError>

Source

pub async fn get_token_meta( &self, account: &str, ) -> Result<TokenMeta, SolscanError>

It fetches the token meta data for a given token address.

Arguments:

  • account: The address of the token contract

Returns:

A Result<TokenMeta, SolscanError>

Source

pub async fn get_market_token( &self, account: &str, ) -> Result<TokenMarketItem, SolscanError>

It fetches the token market item for the given account.

Arguments:

  • account: The address of the token contract

Returns:

A Result<TokenMarketItem, SolscanError>

Source

pub async fn get_chain_info(&self) -> Result<ChainInfo, SolscanError>

It gets the chain info from the Solana blockchain.

Returns:

A Result<ChainInfo, SolscanError>

Trait Implementations§

Source§

impl Default for SolscanAPI

Creating a default implementation for the SolscanAPI struct.

Source§

fn default() -> Self

It creates a new instance of the SolscanAPI struct.

Returns:

A new instance of the SolscanAPI struct.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,