Transfer Native Tokens with Storage Deposit
Transferring native tokens is similar to transferring base tokens. The output that you create on the receiver's address however needs to have base tokens to cover for the storage deposit. Therefore, there are two ways to transfer native tokens:
- Sending native tokens together with the required storage deposit. The sender loses access to the storage deposit in this case, as shown in transaction E.
- Sending native tokens using the Storage Deposit Return Unlock Condition. The receiver has to claim the transfer by refunding the sender's storage deposit. The sender doesn't lose the storage deposit this case, as shown in transaction F.
Example Transactions
Conditional Transfer of Native Tokens
Add the unlock conditions
In order not to lose access to the storage deposit, two additional unlock conditions are defined on Basic Output #7 in Transaction F:
- A Storage Deposit Return Unlock Condition that forces the consumer of the output to refund Return Amount of base tokens to Return Address.
- An Expiration Unlock Condition that defines a time window the recipient has to claim the transfer. If they don't do so, ownership of Basic Output #7 bounces back to the sender and the Storage Deposit Return Unlock Condition is ignored.
- The expiration time is compared to the timestamp of the confirming milestone to decide whether the unlock is valid or not.
Transaction F shows the creation of a conditional transfer:
Claim the transfer
Once the transaction is created, the recipient can claim the transfer before the expiration deadline. Transaction G shows a successful claiming. Note that:
- The recipient needs to sweep the native tokens into an output they already own to cover for the storage deposit, hence Basic Output #8 is unlocked in the transaction.
- Basic Output #9 refunds the sender with the storage deposit used to create Basic Output #7.
Related Tutorials
- iota.js
Related How-to Guides
- wallet.rs
Related Code Examples
- iota.js