Batch transaction in Near

One of core concept of how Near work is transaction is not atomic (for external call in a transaction)

However, there still a thing that i want to ask. In there, one transaction may have many actions. This method signAndSendTransaction (NEAR-API-JS Cookbook | NEAR Documentation) can be used to send batch transaction.

I did try it and it give me interesting result:

  • if i send 2 actions, which one of them will be failed, the whole transaciton will not process (ex: calling 2 action ft_transfer of wrap.near, one valid amt, one exceed amt → the txn will be failed, none of the action success) → this sound like a atomic way for me if i can do it with external call in one of the action too. so i came with the 2nd try.
  • if i send 2 actions, one action will make the contract call external transcation (which all valid), and the second action will be failed, it will always process the failed action first lead to fail the whole transaction and not come to the external call anyway. (how Near archived this? Maybe run in local state of both action first, then external call after it?)

My question here is that, how does these transaction work excactly? does Near behave differently in these batch transaction that can atomic revert all? if i can find a way to call external contract in one of the action, will the external transaction be reverted with the batch transaction too?

Hey!

This forum is primarily used for ecosystem governance and, although some :brain: devs do hang around, it might be better for you to seek your answer from:

Discord#dev-support

or

near.zulipchat.com