Skip to content

Commit

Permalink
fix: update README for current function signature
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemaccana committed Sep 11, 2023
1 parent e6c9e82 commit a771b92
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,30 @@ Gets a keypair from a file - the format must be the same as [Solana CLI](https:/

To load the default keypair `~/.config/solana/id.json`, just run:

```
const keyPair = await Keypair.fromFile();
```typescript
const keyPair = await getKeypairFromFile();
```

or to load a specific file:

```
const keyPair = await Keypair.fromFile('somefile.json');
```typescript
const keyPair = await getKeypairFromFile("somefile.json");
```

or using home dir expansion:

```
const keyPair = await Keypair.fromFile('~/code/solana/demos/steve.json');
```typescript
const keyPair = await getKeypairFromFile("~/code/solana/demos/steve.json");
```

## getKeypairFromEnvironment

Gets a keypair from a secret key stored in an environment variable. This is typically used to load secret keys from [env files](https://stackoverflow.com/questions/68267862/what-is-an-env-or-dotenv-file-exactly).

```typescript
const keyPair = await getKeypairFromEnvironment(TEST_ENV_VAR_BASE58);
```

### Secret key format

Secret keys can be in either the more compact base58 format (`base58.encode(randomKeypair.secretKey);`), like:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solana-developers/node-helpers",
"version": "1.0.0",
"version": "1.0.1",
"description": "Solana helper functions for node.js",
"main": "index.js",
"private": false,
Expand Down

0 comments on commit a771b92

Please sign in to comment.