need some assistance in creating an associate token account from the program. So we need users to be sending a SPL token to our program. To keep the account unique for each user we want to create PDA for each user. Each user's PDA will have an ATA, where users will send their tokens to. So program will then withdraw the tokens and do the necessary actions.
I am fairly new to Rust and stuck while creating ATA from the program. Below is the code I am trying to execute.
invoke(
&create_associated_token_account(
initializer.key,
pda_ata.key,
token.key,
associated_system_program.key
),
&[initializer.clone(), pda_ata.clone(), token.clone(), associated_system_program.clone()],
)?;
Error I see in Logs:
'Instruction references an unknown account xxxxxxxx',
failed: An account required by the instruction is missing
So I want a user to
- send 5 CUSTOM TOKENS
- Program to Receive above 5 tokens and add to the user's tally.
- Once there are 10 TOKENS received then a user can perform an action.
What should be the best approach to this via one INSTRUCTION?
create PDA for each user create ATA for the PDA program to transfer from User's ATA to PDA ATA
Thanks