Solana: How to find out the price of the Raydium token using the Solscan API

Getting Radium Token Price using Solscan API: A Quick Guide

Solana has recently emerged as a leading platform for decentralized applications (dApps), and its native cryptocurrency, Raydium Token (RAY), has gained significant attention. As a popular trading pair on Solana’s blockchain, RAY is closely watched by traders and investors alike. In this article we will explore the process of getting the current price of Raydium Token using the Solscan API (PRO).

What is the Solscan API?

The Solscan API (PRO) is a powerful tool that allows developers to interact with Solana’s blockchain programmatically. It provides access to a variety of APIs, including Solscan, which offers a range of features and tools for building custom applications.

Getting Started: Setting Up the Solscan API

To use the Solscan API, you will need to register an account on the Solscan platform and obtain your API key. Here’s a step-by-step guide:

  • Go to the [Solscan website] (

  • Click on “Create Account” and follow the instructions.

  • Fill out the registration form with your email, password, and other details.

  • Verify your account by clicking on the link sent to your email.

Getting a Solscan API Key

Once you’ve registered an account, you’ll receive a unique API key. To use this key in the Solscan API, follow these steps:

  • Log in to your Solscan account and go to the “API Keys” section.

  • Click on “Generate New API Key.”

  • Fill out the form with your API key and other details (e.g., name, email).

  • Download your API key as a JSON file.

Getting Started with the Solscan API

Now that you have your API Key, you can start using it to get the Raidium Token price on Solana. Here’s an example code snippet in Rust:

use solana_sdk::account_info::{AccountInfo, ProgramId};

use solana_sdk::key_pair::Keypair;

use solana_sdk::transaction::Transaction;

// Define the API key and account info for Raydium Token

const RAY_API_KEY: &str = "YOUR_API_KEY";

const RAY_ACCOUNT_INFO: &AccountInfo = &AccountInfo {

pub key : Keypair :: new ( [ 1 , 0 ] ) , // Replace with your public address

pub program_id: ProgramId::from_str("RAY").unwrap(),

};

// Define the transaction to get the Raydium Token price

async fn get_radium_token_price() -> Result<(), Box> {

let mute transaction = Transaction::new();

transaction.set_program_id(PublicKey::from_str("YOUR_PUBLIC_ADDRESS"));

transaction.add_input_account_info(RAY_ACCOUNT_INFO);

transaction.sign(&RAY_API_KEY);

// Run the transaction

let(tx_hash, _, _) = solana_sdk::transaction::run_transaction(transaction).await?;

let transaction_result = tx_hash.as_ref().unwrap();

match transaction_result {

Ok(_) => Ok(()),

Error(e) => Error(Box::new(std::error::Error::from(e))),

} }

} }

// Main function

async fn main() -> Result<(), Box> {

let result = get_radium_token_price().wait?;

if !result.is_ok() {

eprintln!("Error: {}", result);

return ;

} }

// Print the Radium Token price

println!("Raidium Token price: {}", result.unwrap());

Ok(())

} }

Running the Code

Save this code to a file (e.g., get_raydium_token_price.rs) and run it using your favorite IDE or command line. Replace the placeholders (YOUR_API_KEY, YOUR_PUBLIC_ADDRESS, etc.) with your actual Solscan API key, public address, and other details.

Tips and Variations

  • To get the current price of Raydium Token, you can modify the transaction using the get_price function on Solana.

  • You can also use the get_account_info function to fetch information about specific accounts, including their balances and addresses.

اترك ردّاً

لن يتم نشر عنوان بريدك الإلكتروني. الحقول الإلزامية مشار إليها بـ *