Skip to content

Instantly share code, notes, and snippets.

@sigridjineth
Forked from alecchendev/cpi.rs
Created May 24, 2022 07:43
Show Gist options
  • Select an option

  • Save sigridjineth/c99f161d57733c0e465301b12419ff65 to your computer and use it in GitHub Desktop.

Select an option

Save sigridjineth/c99f161d57733c0e465301b12419ff65 to your computer and use it in GitHub Desktop.
// calling token program to burn some tokens
invoke(
&spl_token::instruction::burn(
&spl_token::id(),
user_token_account_ai.key,
vending_machine_mint.key,
&user.key,
&[],
price,
)?,
&[user_token_account_ai.clone(), vending_machine_mint.clone(), user.clone()],
)?;
// allocating data for a mint account
invoke_signed(
&system_instruction::create_account(
user.key,
pool_mint_ai.key,
rent::Rent::get()?.minimum_balance(mint_data_len),
mint_data_len as u64,
&spl_token::id(),
),
&[user.clone(), pool_mint_ai.clone(), system_program.clone()],
&[pool_mint_seeds],
)?;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment