Token Transfer flow
In the previous article we saw an example of token transfer between accounts found in different shards. That example was simplified and missed a few steps in the process. That was intentional, to keep the article and the video short yet explanatory, in order to give you a bigger picture for understanding concepts. In this article we’re going to have a look at the same data flow, but in detail and we will consider two additional scenarios:- Token transfer between accounts found in different shards
- Token transfer between accounts found in the same shard
Attach extra gas; get refunded! …… From NEAR Protocol docs Gas. Attach extra gas; get refunded!
- If you attach more gas than needed, you’ll get refunded
What refunds mean in terms of data flowIt means that literally every Transaction includes a refund.
Token transfer between accounts found in different shards
Basically it is an extension of the example from the NEAR Data Flow article. Assume we have two accounts alice.near and bob.near. They belong to differentShards. alice.near sends a few tokens to bob.near.
A Transaction signed by alice.near is sent to the network. It is immediately executed, ExecutionOutcome is the output or result from converting the transaction into a Receipt.

Receipt created as result of the Transaction follows these rules:
- It will be executed not earlier than next
Block - It must be executed on the receiver’s
Shard
Shard that’s why the Receipt moves to the receiver’s Shard and is put in the execution queue.
In our example the Receipt is executed in the very next Block.

ExecutionOutcome for the Receipt will be another Receipt that is refunding the Gas to the sender. bob.near has received tokens from alice.near. Now, alice.near becomes the receiver for a new (and last) Receipt (keep in mind the sender in this Receipt is always system).
Keep in mind rule #2: the Receipt must be executed on the receiver’s Shard. So this Receipt moves to the Shard where alice.near belongs to. And it is the last execution in this process.

Token transfer between accounts found on the same shard
Let’s have a look at the example where both accounts are on the sameShard. The process is the same as in the previous example, except there are no Receipts moving from one Shard to another.
A Transaction signed by alice.near is sent to the network. It is immediately executed, ExecutionOutcome is the result of converting the transaction into a Receipt.

Block. It is executed in the next Block, and the ExecutionOutcome result is a new Receipt with the refund to the initial sender, alice.near.
The Same rules apply to this Receipt, it is put into the execution queue and executed in the next Block.
