0

I'm trying to write a ICO contract with Anchor, and stuck with deposit method, which supposed to transfer SOL from user to protocol treasury, and receives corresponding ico token.

the problem is, I cannot transfer token from protocol to user, since this 'deposit' method is supposed to executed with only user authority, which suppposed to be provided by wallet adapter connected from client side.

I found a suggestion to use a PDA to sign the transaction, but now it throws an owner error, and I'm not sure if this is the right approach.

Am I missing something here?

I'd appreciate any guide or advice on this issue, or if I'm on the right track

Thanks in advance!

Below is the link to the current codebase.

https://github.com/kyoung0119/presale_contracts_solana

1 Answer 1

1

if i understood well your case, here is the flow i would use :

  1. you have a PDA with the ICO tokens
  2. the user send funds to your program (it goes then in another PDA, for SOL for example)
  3. in the same instruction, you send ICO tokens from the PDA to the user token account
1

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.