2

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 1

4

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.