Is there any way to get spl decimal in program? Sorry about this, this question is too short so I have to add this sentence.
1 Answer
If you are writing a program using Anchor, then you can do the following:
Use anchor_spl
to get the Mint
type
use anchor_spl::token::Mint;
Then you can do this in the Accounts struct for your instruction, which deserialized the mint account data for you:
#[account(mut)]
pub mint: Account<'info, Mint>,
Within your instruction you should then be able to access the decimals for the mint like this:
*ctx.accounts.mint.decimals