solana-labs / solana

Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.
https://solanalabs.com
Apache License 2.0
13.21k stars 4.29k forks source link

What Account to use for SPL Token Transfer After Recipient's Derived Token Address Ownership Transferred #20722

Closed ozyman42 closed 3 years ago

ozyman42 commented 3 years ago

Problem

I'm noticing that with many NFT marketplaces, they transfer ownership of the NFT by having owners transfer control of the SPL token account, rather than creating a token account for the recipient based on the derived address. For example, this token account is being transferred between owners https://explorer.solana.com/address/BW766zFWF5PRr5LssdJv2zoCkUAwvELwaLswho4ZMPmB (see transaction history how the authority keeps changing hands).

When I call Token.getAssociatedTokenAddress with mint 3MwVdf1kEDRUU4qTfoHk1u363qJGxrCYHT5RBAEBQGLs and owner BAJkBrrMZusHYingeqmvKND7LZBYRLYRMjDtFJ7wbjkT I get the derived address BW766zFWF5PRr5LssdJv2zoCkUAwvELwaLswho4ZMPmB. But now since BW766zFWF5PRr5LssdJv2zoCkUAwvELwaLswho4ZMPmB has a new owner than the original owner, we can run into a situation where I want to send the SPL token to original owner BAJkBrrMZusHYingeqmvKND7LZBYRLYRMjDtFJ7wbjkT, but I can't use BW766zFWF5PRr5LssdJv2zoCkUAwvELwaLswho4ZMPmB as the destination in the Token.createTransferInstruction instruction, since it has the wrong owner, and I can't generate a new keypair to use for creation of a new recipient associated token account because then I get the error Associated address does not match seed derivation.

Proposed Solution

I guess I need to transfer ownership of the token account I'm sending from, but this solution seems to just perpetuate a problem where account ownership is being transferred rather than creating the derived account for a recipient. Account transfer works for NFTs where the supply is 1, but I don't see this account transfer working in cases where I want to transfer some fungible SPL tokens but not all.

ozyman42 commented 3 years ago

Closing. Realized this should be in the SPL repo. Created https://github.com/solana-labs/solana-program-library/issues/2514

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any activity in past 7 days after it was closed. Please open a new issue for related bugs.