Search code examples
nearprotocol

How do I transfer an account between parties on the NEAR platform?


From the docs:

Accounts can be atomically and securely transferred between parties as a native transaction on the network.

I know the currently support Actions on the network are:

CreateAccount
DeployContract
FunctionCall
Transfer
Stake
AddKey
DeleteKey
DeleteAccount

source: https://nomicon.io/Runtime/Actions.html

I know from NEAR Shell that the DeleteAccount action takes an account to be deleted (the "sender") and a beneficiary account (the "receiver").

Is this what is meant by "atomically and securely transferred between parties"? Applying the DeleteAccount action?

Or am I missing something?


Solution

  • The idea behind the secure transfer is the ability to replace access keys. Let's say you have an account alice and you want to transfer this account to me.

    1. I give you a public key (without revealing the private key).
    2. You create a transaction and sign it with your current private key. The transaction has 2 actions: remove your key, add my public key.

    Now alice account has my public key, so only I have access to it. And you don't have access to alice anymore because it doesn't have your key, and you don't know my private key.