Skip to content

Instantly share code, notes, and snippets.

@alecchendev
Created April 9, 2022 03:11
Show Gist options
  • Save alecchendev/9479d963bb12d9898b3a5ae2e9fe78be to your computer and use it in GitHub Desktop.
Save alecchendev/9479d963bb12d9898b3a5ae2e9fe78be to your computer and use it in GitHub Desktop.
// import Pack trait
use solana_program::{
program_pack::Pack,
};
// import type
use spl_token::{
state::Mint,
}
// code inside of `process_instruction`
// mint_account is of type `AccountInfo` retrieved previously
let mint = Mint::unpack_from_slice(&mint_account.try_borrow_data()?)?;
msg!("mint decimals: {}", mint.decimals);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment