-
Notifications
You must be signed in to change notification settings - Fork 853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support the JSON key file format that solana-keygen
uses
#1460
Comments
One reason not to do this is that Two thoughts: 1 – This already sort of works in Node: const SECRET_KEY_BYTES = require('/home/me/.config/solana/id.json');
const { Keypair } = require('@solana/web3.js');
console.log(Keypair.fromSecretKey(new Uint8Array(SECRET_KEY_BYTES))); 2 – We could offer a separate npm package of server utilities that did this kind of stuff, as wrappers around |
Understood re: making sure web3.js works everywhere (web/server/mobile). The second suggestion - having server-specific functions in a separate package - sounds good. I personally have a bunch of server-specific helpers, I know @nickfrosty does too, I wouldn't be surprised if many Solana users are effectively rewriting the same things, and we should save them the effort. Having this kind of thing in a separate server package means:
|
I definitely agree that it'd be nice to have these sorts of helpers in a package somewhere. Would be useful for teaching too! Maybe a new repo under |
I like that idea. My hope is that many such packages will spring up around the new web3.js, because its API is so flexible. It would be difficult to do such a thing without hacking or subclassing the old |
Actually making this (we have a lot of noise right now in some courses due to adding functions that should be in a package somewhere). Will link here once I get |
@steveluscher Done. Want to review? solana-developers/helpers#1 |
@steveluscher or @mikemaccana I recommend closing this issue since the |
Because there has been no activity on this issue for 7 days since it was closed, it has been automatically locked. Please open a new issue if it requires a follow up. |
Motivation
The Solana CLI and docs use a file format which has a single secret key inside a JSON file. web3.js doesn't currently directly support these files.
This enhancement adds
Keypair.fromFile()
to load the Solana CLI secret key files.Example use case
A user is using the solana CLI to perform a task. The user has created a secret key, by default, in
~/.config/solana/id.json
and used this via Solana CLI. They then wish to use this same keypair in web3.js.Right now the user has to work out how to do this themselves.
This proposal makes web3.js support the Solana CLI JSON files itself.
Details
This would work:
Then to use, just:
or:
or:
The text was updated successfully, but these errors were encountered: