anza-xyz / solana-pay

A new standard for decentralized payments.
https://solanapay.com
Apache License 2.0
1.29k stars 450 forks source link

TokenAccountNotFoundError #182

Open tolgaand opened 1 year ago

tolgaand commented 1 year ago

It uses this package to send tokens to users and verify transactions. But when I send tokens to a user who has never had a token account, I get a "TokenAccountNotFoundError" error.

To solve this problem, the createTransfer file used in; How to convert the function "getAssociatedTokenAddress" to the function "getOrCreateAssociatedTokenAccount"?

flodef commented 1 year ago

I understand your point... However, I disagree on the way to solve the problem.

Let's say there is a merchant receiving the token. It has first to create the token he wants to receive, once and for all. When the customer is paying, he only needs to pay his own transaction fee, not to create the token for the merchant.

Otherwise, it could be like a tax if after receiving a payment, the merchant delete his token account (and receive some sol for closing the account). Then next customer create again the merchant token account, etc.

tolgaand commented 1 year ago

I understand your point... However, I disagree on the way to solve the problem.

Let's say there is a merchant receiving the token. It has first to create the token he wants to receive, once and for all.

When the customer is paying, he only needs to pay his own transaction fee, not to create the token for the merchant.

Otherwise, it could be like a tax if after receiving a payment, the merchant delete his token account (and receive some sol for closing the account). Then next customer create again the merchant token account, etc.

I hadn't thought of that, thank you.

flodef commented 1 year ago

You're welcome. Happy to have been of some help :-)

yamijuan commented 1 year ago

What if the merchant provides a TokenAccount instead of a wallet address? this is our case and it fails since the recipient is already a token account

flodef commented 1 year ago

Hey There, great question! My advice would be that you go on Solscan (or any other Solana explorer) by typing https://solscan.io/account/MerchantTokenAccount. From there, you can easily spot the account owner and set it up. (eg : https://solscan.io/account/AAhtuv3wpwNSQFzBCKGnb4fhSxX4LY4VgRjEH9tqK52k where the account owner is [BNnncdQZ9YokyQJX8of4K2YGw3pvLt2SVkXK131E1nFy]) Hope it helps :-)