0

What is the difference between a transaction and a transfer? From my understanding so far, and according to the answer provided in this question, transactions are meant for exchanges using native SOL, and transfers for spl-tokens transactions are for anything that needs to be written on the blockchain, and a transfer is an instruction that can be included in a transaction (as clarified to me in the comments, thank you @xenoshiba).

But when I look at some accounts on an explorer like solana.fm, I sometimes see SOL being sent to another account under the "transfer" section rather than the "transaction" section, as shown in the picture below to clarify:

Snapshot of a "transfer" of SOL on solana.fm

How does one "transfer" SOL to another account (instead of using a "transaction") when using the JavaScript client and libraries @solana/web3.js and @solana/spl-token, like in the picture above?

6
  • A transfer is a type of transaction
    – tymur999
    Commented Jun 23 at 23:29
  • 1
    "transactions are meant for exchanges using native SOL, and transfers for spl-tokens" - you get it wrong. a transaction is anything that requires to be "written" in the blockchain, and transfer is an instruction that can be included in a transaction.
    – xenoshiba
    Commented Jun 23 at 23:44
  • Thank you for the correction @xenoshiba. But why do explorers like solana.fm list transfers separately from transactions, and how does one do a transfer using JavaScript? I sent some SOL between test accounts on the Devnet, but they showed up only in transactions and not transfers. Commented Jun 24 at 1:51
  • Maybe you share an example transaction signature that displays the way you described (with a transfer rather than a transaction)?
    – chalda
    Commented Jun 24 at 8:05
  • @CryptoCurious the reason why the explorer separated it is just for UX reasons, ie. users will be able to easily see if a "transfer" instruction has occured in THAT transaction. if you go to the transaction tab, you will also see that "transfer" instruction as well. I think you are being confused about SPL transfers - there are actually 2 types of transfers here: one is the native transfer instruction (which you see in that transfer tab) which is used to transfer native token (SOL), and the other is SPL transfer, which is used by the rest of the tokens in Solana (SPL Token).
    – xenoshiba
    Commented Jun 26 at 18:20

1 Answer 1

1

As tymur999 said: A transfer is a special type of transaction that only changes the SOL balance of two accounts or the balance of two token accounts (one sender and recipient).

From Solana's point of view, transfers aren't treated differently than any other type of transaction that does more or less things. SolanaFM and other block explorers just showcase them differently to make it easier to read for non-technical people & so that if your account is getting spammed by other transactions (e.g. spam NFTs) you can still efficiently find "real" transfers you care about.

You also asked how to execute a transfer in javascript. Here's how to do it for spl tokens and here's how to to do it for sol.

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.