There are two things we'll want to do:
- Create a random seed phrase for the user when they visit the crossword puzzle. This will be used if they win and don't have a NEAR account and wish to create one. They can then paste this seed phrase into NEAR Wallet afterward.
- Turn the crossword solution into a key pair, instead of just hashing it.
We can add the
near-seed-phrase package to our project with:
Code snippets for this chapter
At this point in the tutorial, it's more difficult to share code snippets that are both meaningful and meant to be copy/pasted into a project.
The snippets provided might differ slightly from the implementation of the completed code for chapter 3, which might be the best place to look for the functioning code.
The last line should look familiar. We did something similar in the last chapter, except we used the
WalletConnection's account to do the function call.
This time we're using an
InMemoryKeyStore instead of the browser, as you can see toward the middle of the snippet.
We have now used almost all the key stores available in
UnencryptedFileSystemKeyStore— early on, when we used the NEAR CLI command
near login, this created a file in our operating system's home directory containing a private, full-access key to our account.
BrowserLocalStorageKeyStore— in the last chapter, when the user first logs in, the function-call access key is saved in the browser's local storage.
InMemoryKeyStore— for this chapter, we'll simply use the computer's memory to store the private key derived from the crossword solution.
You can have multiple key stores
Technically, there's another type of key store called the
Say you want to look for private keys in various directories. You can essentially have a list of
UnencryptedFileSystemKeyStore key stores that look in different places.
MergeKeyStore when you might want to look for a private key in more than one place.