Solana Dev 101 - File system wallets + How to create a custom wallet
This blog aims to shed light on what file system wallets are, how to create them, and how to utilize them. Let's get started!
What is the a file system wallet
A file system wallet refers to a wallet where the cryptographic keys are stored as a file on your device. These keys are used to sign transactions and authenticate ones identity when interacting with the Solana network. Unlike hardware wallets or web-based wallets, file system wallets store the keys locally on the device rather than on external hardware or in the cloud. This means that the user has direct control over their keys and is responsible for keeping them secure.
The main advantage of a file system wallet over other types of wallets is its simplicity and flexibility. There's no need for a web interface, no plugins, and no dependencies. It's just a file that you can manage yourself,
How to create a file system wallet
It is really easy to create a file system wallet.
- First, you'll need to install Solana's command-line tool suite, Solana-CLI, if you haven't already. You can do this using the following command:
Make sure to replace the "v1.8.0" with the latest version.
- With Solana-CLI installed, you can now generate a new keypair, which will be stored in a file. Use the following command to create a new wallet:
This command will create a new keypair and store it in a file named "my-keypair.json”.
How to use a file system wallet
Now that you have your file system wallet, you can use it to sign transactions on the Solana network.
When you want to run a CLI command that requires a wallet, you can use the --keypair option followed by the path to your wallet file. For example, if you want to get the balance of your account, you can use the following command:
Remember, keeping your wallet secure is very important . Never share your wallet file and always keep a backup in a secure location.
You will also be able to use these wallets in your Javascript code. The Solana JavaScript SDK makes it easy to bring these wallets into your code as KeyPairs. Simply add the following line of code:
Make sure to copy the secret key array from the newly created json file and paste it in the parameters.
How to create a custom wallet address
One cool thing about the solana-keygen command is that you are able to create a wallet address that starts and ends with specific characters. This can be great for tracking or setting up easily recognisable wallets.
The solana-keygen command has the choice of both options and subcommands. We will make use of the “grind” subcommand to grind for a vanity key-pair.
If we wanted to create a wallet that starts with “test” we would run the following command:
This will specify that we want the wallet address to start with the string “owen” and that we only want to generate one wallet address.Once this command has been run your machine will now search through millions of keypairs to find a match. It’s important to note that this can be a very computationally heavy task. If you are wanting to choose 5 of more characters it might take a very long time.
There are a lot of options when it comes to creating a custom address, you can see them all by running:
One of the common options is used if you would like a recovery phrase. You can add in the —use-mnemonic flag to achieve this.
Conclusion
File System Wallets on Solana provide a simple and flexible way for developers to create and use wallets. They are easy to set up and allow full control of the wallet and offer some cool customisation options.
While this method might not be suitable for every user due to the level of responsibility it entails, it presents a clear advantage for developers and knowledgable individuals who prefer having full control over their wallet.