Quantcast
Channel: Recent Questions - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 7950

Limiting minting supply of fungible token

$
0
0

I'm trying to understand how to limit max_supply of Mint token (using fungible SPL Token).In example (from this repo):

    pub fn create_token(ctx: Context<CreateToken>, decimals: u8, amount: u64) -> Result<()> {        system_program::create_account(            CpiContext::new(                ctx.accounts.system_program.to_account_info(),                system_program::CreateAccount {                    from: ctx.accounts.signer.to_account_info(),                    to: ctx.accounts.mint_token.to_account_info(),                },            ),            10_000_000,            82,            ctx.accounts.token_program.key,        )?;        initialize_mint(            CpiContext::new(                ctx.accounts.token_program.to_account_info(),                InitializeMint {                    mint: ctx.accounts.mint_token.to_account_info(),                    rent: ctx.accounts.rent.to_account_info(),                },            ),            decimals,            ctx.accounts.signer.key,            Some(ctx.accounts.signer.key),        )?;        associated_token::create(CpiContext::new(            ctx.accounts.associate_token_program.to_account_info(),            associated_token::Create {                payer: ctx.accounts.signer.to_account_info(),                associated_token: ctx.accounts.token_account.to_account_info(),                authority: ctx.accounts.signer.to_account_info(),                mint: ctx.accounts.mint_token.to_account_info(),                system_program: ctx.accounts.system_program.to_account_info(),                token_program: ctx.accounts.token_program.to_account_info(),            },        ))?;        mint_to(            CpiContext::new(                ctx.accounts.token_account.to_account_info(),                MintTo {                    authority: ctx.accounts.signer.to_account_info(),                    mint: ctx.accounts.mint_token.to_account_info(),                    to: ctx.accounts.token_account.to_account_info(),                },            ),            amount,        )?;        Ok(())    }

and this is CreateToken structure:

#[derive(Accounts)]pub struct CreateToken<'info> {    #[account(mut)]    pub mint_token: Signer<'info>,    #[account(mut)]    pub signer: Signer<'info>,    ///CHECK:    #[account(mut)]    pub token_account: AccountInfo<'info>,    pub system_program: Program<'info, System>,    pub token_program: Program<'info, Token>,    pub associate_token_program: Program<'info, AssociatedToken>,    pub rent: Sysvar<'info, Rent>,}

So i probably should use something like:

#[account(mut)]    pub mint: Account<'info, Mint>,

to get supply parameter, but how to init(get details of) this account in createToken method? IS there any method/example to it?


Viewing all articles
Browse latest Browse all 7950

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>