3

I wanted to inquire if anybody knows how to tranfer a spl-token from an account when the account receives a SOL because I'm a novice Rust/Solana developer.

Despite reading the https://docs.solana.com/, I was unable to locate any information about SPL transfers. I require a website for token minting.

Help would be greatly appreciated, thanks!

2 Answers 2

3

You can send SPL-Tokens by using CPI on the token program's transfer instruction.

For example:

spl_token::instruction::transfer(
  token_program.key,
  source.key,
  destination.key,
  authority.key,
  &[],
  amount,
)?;
invoke_signed(
  &ix,
  &[source, destination, authority, token_program],
  signers,
)

You can find a more in depth example by looking at how the token-swap program uses CPI to transfer spl-tokens

0
1

Go through the SPL Token Section of the CookBook and you can find your answers there tag me here if you still dont get your answer's

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.