A while back we deployed a smart contract on to the EOS mainnet (as setupaccount) to help facilitate the creation of new accounts. While we have yet to really utilize or promote this contract, it’s been successfully functioning and creating accounts for some who have stumbled into it.
Today I’m writing up a quick guide on how you can use this contract to create an account with a simple EOS token transfer and a memo containing the account name and public key.
Note: This process should work with any exchange, unless the exchange itself has blocked withdraws to accounts with smart contracts deployed. I know some exchanges are actively blocking these types of transactions due to the various “token transfer mining” contracts out there. If your exchange doesn’t work with this guide, we’d recommend you ask them to whitelist the
setupaccountcontract. Also feel free to refer them to this post as an explanation of what the contract does!
Requirements to get started
To get started and use the contract to create an account, here’s what you’ll need…
- A 12-character long account name that you’d like to use
- An EOS public key you’d like to assign for the new account
1. Finding an available account name
The first thing you’ll need is the account name itself, which has to be exactly 12 characters and can only contain lower case letters
a-z and the numbers
1-5. Some examples of valid account names:
teamgreymass greymass1111 hiaaron12345
2. Generating an EOS Public Key
The next step is to generate a key pair that will be able to control the account. This keypair consists of both a public key and a private key.
- The Public Key starts with either
PUB_K1and is public information that can be shared with contracts like this. Public Keys are recorded publicly on the blockchain.
- The Private Key starts with either
PVT. This key is the one you must keep private, as anyone with access to this key can perform any actions with the account (including taking control).
If you are using Anchor, you can generate new keypairs by going into Tools, and then selecting Manage Keys. A button exists at the top that says Generate Key pairs which will allow you to create a new set of keys.
After generating a new key pairs, it is recommended that you:
- Use the button at the bottom to Save Keys to Wallet for use within Anchor.
- Use the button in the top right to Copy to Clipboard and save those keys someplace safe, preferably on an external storage device that cannot be accessed regularly. For added security, you can save these encrypted somewhere with a password.
- Back up your wallet now that it contains new keys.
Note: Another option, if you have a Ledger hardware device and it’s connected, is to go into Tools and then Ledger, and click the Load Public Key button on that interface. This will give you the public key for your Ledger hardware wallet, which can be used in this process.
Once you have your private keys stored someplace safe, and know what your public key is, you’re ready to proceed!
Creating an account by sending EOS tokens
Now with an account name and public key in hand, you’re ready to create an account.
To do this, you’ll need to send 1.0000 EOS to the
setupaccount contract with a specific memo. If the exchange or wallet you’re using to send these tokens doesn’t support using the memo field while transferring tokens, this process will not work. Luckily the contract is smart enough to reject the transaction and prevent you from proceeding if a memo is not specified.
The memo used will specify the account name and public key for the new account. So, if you wanted to create an account with the following information:
- Account Name:
- Public Key:
You need to combine the two with a dash, no spaces, and use it as the memo field for the transfer. Using the information above as an example, the memo for the transfer/withdraw would be:
So to recap, for me to create this account, I would be withdrawing 1.0000 to setupaccount, and specifying the memo above.
The smart contract will use the 1 EOS to create the new account (buying RAM, staking a small amount, etc) and deposit any remaining EOS tokens as a liquid balance. There’s no fees for using the contract itself, though the creation and purchase of RAM will deduct a variable amount from it.
If the transfer/withdraw is successful, a new account will be created and you should be able to view it on block explorers and now import it into your wallet!
Note: The account may not be found immediately due to a bug in the account lookup APIs. This bug should be resolved in one of the next EOSIO releases. If you cannot find your account immediately, just let us know, as the temporary workaround for this issue is for API providers like Greymass to just restart the API servers. After the restart, the account will be found.