I think there is a link in the article to make it happen but here is a possible solution.
In the src directory just make a file called createKeyPair.js and add this code:
// Shoutout to Nader Dabit for helping w/ this! // twitter.com/dabit3
const fs = require('fs') const anchor = require("@project-serum/anchor")
const account = anchor.web3.Keypair.generate()
fs.writeFileSync('./keypair.json', JSON.stringify(account))
Then inside your app run: node createKeyPair.js which should create a keypair.json (which is what holds the keypair for persistence)
Then in the App.js import the json file import kp from './keypair.json'
and then whereever in your App.js you are calling: let baseAccount = Keypair.generate();
Just replace with the following:
const arr = Object.values(kp._keypair.secretKey) const secret = new Uint8Array(arr) const baseAccount = web3.Keypair.fromSecretKey(secret)
That should be it. now it should be persistent on loading for anyone connected to your app.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think there is a link in the article to make it happen but here is a possible solution.
In the src directory just make a file called createKeyPair.js and add this code:
// Shoutout to Nader Dabit for helping w/ this!
// twitter.com/dabit3
const fs = require('fs')
const anchor = require("@project-serum/anchor")
const account = anchor.web3.Keypair.generate()
fs.writeFileSync('./keypair.json', JSON.stringify(account))
Then inside your app run:
node createKeyPair.js
which should create a keypair.json (which is what holds the keypair for persistence)
Then in the App.js import the json file
import kp from './keypair.json'
and then whereever in your App.js you are calling:
let baseAccount = Keypair.generate();
Just replace with the following:
const arr = Object.values(kp._keypair.secretKey)
const secret = new Uint8Array(arr)
const baseAccount = web3.Keypair.fromSecretKey(secret)
That should be it. now it should be persistent on loading for anyone connected to your app.