nearprotocolnear

How do I use 'create_account_and_claim'


I've had some success creating accounts using create_account with the JSON RPC.

I've read from the co-founder of NEAR that we can create accounts and generate links for those accounts to be claimed.

The documentation doesn't mention it, I guess they're updating.

When I try to use call it I get an error saying left and right accounts don't match


Solution

  • NEAR Linkdrop contract README has the description on the high-level: https://github.com/near/near-linkdrop

    Receiver, that doesn't have NEAR:

    1. Receives link to the wallet with privkey1.
    2. Wallet creates new key pair for this user (or they generate it via HSM) (pk2, privkey2).
    3. Enters the new_account_id receiver want for their new account.
    4. Wallet creates a transaction to create_account_and_claim(new_account_id, pk2).
    5. Contract creates new account with new_account_id name and pk2 as full access key and transfers NEAR that Sender sent.

    P.S. This linkdrop contract is exactly the one that is deployed to the account that is named near on mainnet.