From edb0a7deeafd240fb5d6df6704407121e9767932 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Wed, 28 Oct 2020 10:48:23 +0800 Subject: [PATCH] Document self-transfer behavior (#743) --- docs/src/token.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/src/token.md b/docs/src/token.md index 3beb9c06..8b57bed9 100644 --- a/docs/src/token.md +++ b/docs/src/token.md @@ -362,10 +362,6 @@ Accounts hold token balances and are created using the `InitializeAccount` instruction. Each Account has an owner who must be present as a signer in some instructions. -Balances can be transferred between Accounts using the `Transfer` instruction. -The owner of the source Account must be present as a signer in the `Transfer` -instruction. - An Account's owner may transfer ownership of an account to another using the `SetAuthority` instruction. @@ -375,6 +371,19 @@ instruction should be atomically processed with the system instruction that creates the Solana account by including both instructions in the same transaction. +### Transferring tokens +Balances can be transferred between Accounts using the `Transfer` instruction. +The owner of the source Account must be present as a signer in the `Transfer` +instruction when the source and destination accounts are different. + +It's important to note that when the source and destination of a `Transfer` are +the **same**, the `Transfer` will _always_ succeed. Therefore, a successful `Transfer` +does not necessarily imply that the involved Accounts were valid SPL Token +accounts, that any tokens were moved, or that the source Account was present as +a signer. We strongly recommend that developers are careful about checking that +the source and destination are **different** before invoking a `Transfer` +instruction from within their program. + ### Burning The `Burn` instruction decreases an Account's token balance without transferring