Generating Wallets

In this section we’re going to learn how to generate Keystores for your wallets. A Keystore is a file that contains the information for your public/private key, encrypted by a secret aka password. By using Keystores you will avoid keeping your private key in plaintext.

I’ve provided a “generate-wallets.py” script that makes this section quick and gets you straight into botting.

5. Pick a secret phrase to encrypt your wallets

Rename “sample.env” to “.env”. Edit it and choose a long and unique/random string.

This acts like a password for your wallets. Don’t lose or let anyone else see it!

6. Create 3 new wallets

You only need one of these commands for now. Pick A if you are not adding your new wallets to Rabby/Metamask yet.

Type these commands into the Terminal of PyCharm.

You will need 3 wallets to complete this tutorial

a) Type this to create a wallet. This will create 3 wallets and show you the public keys.

python generate-wallets.py --create 3

Example Result:

Public Key: 0x123A1b7b4F176Bd83F2a42cb59e3c1A722B2685b

Public Key: 0x36951A5Cd1B96A9e702Bd3Ef7BC50eD7CA5bB36a

Public Key: 0x4206230f06D014F249b282ddb59a7D311C18879f

b) To create wallets and immediately show their private keys too

python generate-wallets.py --create 3 --show-private-keys

Example Result:

Public Key: 0x123A1b7b4F176Bd83F2a42cb59e3c1A722B2685b
Private Key: 0x08e33dbb7d4bedcd719dbd86b26d0d7150a2db043e4c06c67983f4b5c77a6a89

Public Key: 0x36951A5Cd1B96A9e702Bd3Ef7BC50eD7CA5bB36a
Private Key: 0xff14c9a660f96f1de66701d9c4f5b3403c70b103da4de3806f6faffd72a214a4

Public Key: 0x4206230f06D014F249b282ddb59a7D311C18879f
Private Key: 0xcd944e40e665e839b664396b2119a4d183f55e3e18acb841d148b36e117648f8

c) If you just want to view the private key of an existing wallet

python generate-wallets.py --show-private-keys 0x123A1b7b4F176Bd83F2a42cb59e3c1A722B2685b

Example Result:

Public Key: 0x123A1b7b4F176Bd83F2a42cb59e3c1A722B2685b
Private Key: 0x08e33dbb7d4bedcd719dbd86b26d0d7150a2db043e4c06c67983f4b5c77a6a89

All created wallets will be stored at such paths:

./data/wallets/0x123A1b7b4F176Bd83F2a42cb59e3c1A722B2685b/keystore

7. Import the private keys to Rabby/Metamask (optional)

You can skip this step if you want. It’s solely to help with manual intervention and debugging if you want to do something quick with your wallets outside of Python.

Note that handling your private key this way is typically not secure but it’s the only way to import it into a browser wallet. Please don’t have any keyloggers running if you can help it 🥴

8. Edit your “.env” file

Fill in wallet A/B/C with the 3 public keys you generated above.

Now we’re ready to automate our workflow. Let’s create the bot logic next.

Last updated